C2 can detect geometric shapes drawn by Canvas?

0 favourites
  • 4 posts
From the Asset Store
Pixel Destruction like in "Worms" (Drawing Canvas based)
  • 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.

  • 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.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks for the help,

    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)