I'm building a prototype hybrid game, a HTML 5 canvas inside a WKWebView
, that is intended to help kids learn how to recognise and write letters. Below is an example screenshot of a desired scenario: the user tracing inside a letter
The question is how to determine when/if they've completed the task. I've seen .isPointInPath()
used frequently in tutorials like this one. From this I know how to determine if the current plotted coordinate is inside another context path, but I don't know where to go from there. I'm drawing the letter using:
ctx.font = '400pt -apple-system';
ctx.fillStyle = 'rgba(0,0,0,.1)';
ctx.fillText('S', 32, 500);
I've thought about dividing the letter into hotspots, first seeing if the point is inside the overall shape and then if it, and the other points, have completed all the hotspots. This feels inelegant however. What is the best approach to solving this problem?