Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can use alpha masking. I will use your example and explain further.</p> <p>The general idea is to insert a hidden mask which is basically an image with a predefined area that counts as a correct trace. You define that area using a color, for example the color red. </p> <p>So now you have an image with a red A. You overlay that image on your dashed line and you make it transparent (alpha channels). When the user draws, all you have to do is check whether touch events are coming in the same position as red pixels of the hidden layer. If they are, that means that the user is tracing the line.</p> <p>If you do not want to mess around with alpha channels you could be creative and do it in a different way. If I was in your place I would just create a normal image (no alpha channels needed) it could even be in grayscale (which would even be more memory efficient) and draw the different masks on it.</p> <p>e.g. I want the user to trace over 2 letters: an A and a B. I open up any basic image editing software. Create a grayscale image that has the exact same size as the area in which touchevents should be detected. Draw a letter A with color value 100 (gray) and then draw a letter B with color value 50 (darker gray). Save the image.</p> <p>In the application you just load up that image and keep it in memory as a 2d Array. Then you can use the <a href="http://developer.android.com/reference/android/view/View.html#onTouchEvent%28android.view.MotionEvent%29" rel="nofollow">onTouchevent()</a> callback to get the touchevent positions. So, for example if the user touches the screen at postion (120,240) all you have to do is check the value at the image array you loaded earlier on at position [120][240]. If the value at that position is 100 that means the user is tracing over the letter A, if the value is 50 then the user is tracing over the letter B. Other values mean that the user is not tracing correctly.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload