I made a few changes to shape identification.
The first one is add a canvas for draw. You can write
Shapes.canvas = { {80,16}, {240,176} }
to get the figure from that rectangle. You can draw out of the canvas, but the original shape to compare is in that canvas.
And now a little tutorial about shape definition. By example:
Shapes.list = {
{
name = "Triangle",
F = {
{ t=0, p={ 0, 0.8 } },
{ t=0.33, p={ 0.5, 0.2 } },
{ t=0.67, p={ 0.8, 0.8 } },
{ t=1, p={ 0, 0.8 } }
}
},
{
name = "Square",
F = {
{ t=0.00, p={ 0, 0 } },
{ t=0.25, p={ 0.8, 0 } },
{ t=0.50, p={ 0.8, 0.8 } },
{ t=0.75, p={ 0, 0.8 } },
{ t=1.00, p={ 0, 0 } }
}
}
}
Shape.list is the list of shapes that algorithm identifies. In the example two shapes, Triangle and Square.
The shapes are defined by a list of points. The points are a tuple of t (time) and p (point). All the shapes have ordered points from t=0.0 to t=1.0. This is the normalized form of a shape. The points are in a bidimensional canvas from (0.0,0.0) to (1.0,1.0). The first point is the left-top corner of canvas and the second one is the right-bottom corner of the canvas.
The points of the shape define where should be the player pen when shape is draw. In the example Triangle. at 0.33 time it should be near point (0.5, 0.2).
An that's all. ... Well, the player draw shapes in a (0,0) (256,192) screen and time > that 1 second. But the function Shape.Normalize(...) convert the player shape to a Shape in the 0..1 canvas and the 0..1 time.
Zhen.