Question
modify the getWordAtLocation() function in the client-side javascript so it too is aware of the width of the word you are trying to drag. function
modify the getWordAtLocation() function in the client-side javascript so it too is aware of the width of the word you are trying to drag. function getWordAtLocation(aCanvasX, aCanvasY)
{
//locate the word near aCanvasX,aCanvasY
//Just use crude region for now. //should be improved to using length of word etc.
//note you will have to click near the start of the word
//as it is implemented now const
TOLERANCE = 50;
for (let i = 0; i < words.length; i++)
{ if (Math.abs(words[i].x - aCanvasX) < TOLERANCE && Math.abs(words[i].y - aCanvasY) < TOLERANCE)
return words[i]
}
return null
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started