0 Favourites

C2 can detect geometric shapes drawn by Canvas?

  • Hi everybody!

    As I still don't dominate the Canvas object, I ask if is possible to C2 recognize certain shapes drawn by the player, such as an "X" and "check".

    I learned to do it recognize closed shapes, but without discriminating a triangle of a circle, for example.

    I thank you all in advance for your attention and collaboration.

  • Construct 3

    Buy Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Buy Now Construct 3 users don't see these ads
  • R0J0hound, do you have any suggestions for this? ^^

  • Search for "gesture recognition" for a few examples that may help.

    What is usually done is to compare the points of the line drawn instead of the resulting image.

    One way is to evenly divide the drawn stroke and compare that with a saved stroke. The simplest way is if both strokes have the same number of points, but you can do some interpolation if the number is different.

    The comparison can compare the direction or positions of the points. If by location you'll need to scale the strokes to be the same size.

    For each point you add up the differences. Then that sum will indicate how similar the two shapes are. 0 would be identical and anything higher would be less similar. Typically you pick a number that would be good enough to consider it that shape.

    For comparing against multiple shape you'd do the same for each and keep the one that was closest.

    For comparing if a triangle was drawn then you would have to have to do something a bit more clever. Since you could have started drawing the triangle from any point and went either direction.

    One idea would be to find the center of the stroke and find the distances around that to the point. Then you could compare the distances of both strokes at the same angles around the shape.

    Anyway, just some ideas. I've made an example that you can find by searching that does some of the above. There are also some examples made by others as well as a plugin that could be of use.

  • Thanks for the help, R0J0hound.

    I'm not good at math as you, and I'm more designer than programmer, so often I read tutorials and/or study through reverse engineering. ^^

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)
Similar Topics Posts Views Last Post
Unread hot topic
0 Favourites
Spriter/C2 - Spriter 2 Teaser!
1,800 322,201
tarek2's avatar
tarek2
Unread hot topic
0 Favourites
[PLUGIN] Canvas
627 186,685
zenox98's avatar
zenox98
Unread sticky
763 305,664
asikanddestroy's avatar
asikanddestroy