AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |
Back to Blog
Drawn unity symbol watercolor8/23/2023 ![]() To calculate the drawing quality, you will need to sample the user's path in equal distance intervals.Īt each interval, you will find the closest point on the correct shape. This is the point where the X value of both lines will be the same and the Y value of both lines will be the same. Then we find the intersection of these two lines. We are left with (-0.5 + x1, -0.5 + y1) and (1 + x2, 0 + y2), where x1, y1, x2 and y2 are the offsets needed to ensure the lines go through the specified points. We adjust them so that the first goes through the tap start position and so that the second goes through the point where the threshold angle is crossed. The way this is done is by looking at the first two vectors of our shape - in our case (-0.5, -0.5) and (1, 0). Since the point where we detect the change in direction (lower blue cross on the image above) is not the actual corner is, instead it's where the threshold angle was crossed, we need to still determine the actual point to determine the correct scale. ![]() Once this angle differs from the expected angle by some threshold, you assume the user changed drawing direction. To determine the first corner, you should probably keep track of the angle of the vector from the initial tap point to the current tap location. you multiply your vector representation of the expected shape by this scale to get the correct shape which they should draw. The length of the vector from where the touch started to where the first corner is, is the scale of the image you are expecting them to draw. The way you determine the scale of the image is by logging the user's initial touch point and then, every update, the point where their finger is, up until they reach the end of the first line (more on this later). because you know the shape and orientation, you are basically matching the user's finger movement to the expected shape. ![]() So for your triangle, the shape might be represented as the series of vectors: (-0.5, -0.5), (1, 0), (-0.5, 0.5). You will need to think of the shapes in vector form.
0 Comments
Read More
Leave a Reply. |