- 1 - moveTo( x, y )
- 2 - lineTo( x, y )
- 3 - lineStyle( thickness, color )
- 4 - beginFill( color )
- 5 - endFill()
lineTo( x, y ) - adds vert to vector
endFill() - calls drawPolygon
I’ve had a lot of success using these functions for simple shapes, but I I’ve just come across a bug while trying to fill a more complex shape, using only the above functions.
For educational purposes I’m recreating a game of Worms, and using a single polygon to try and render the water using a sine-wave.
It works for basic concave shapes, like an arrowhead, e.g:
m_water.beginFill( 0x0000FF7F ); // rrggbbaa
m_water.moveTo( cx + 100, cy + 0 );
m_water.lineTo( cx + 0, cy + 100 );
m_water.lineTo( cx + 50, cy + 0 );
m_water.lineTo( cx + 0, cy - 100 );
m_water.lineTo( cx + 100, cy + 0 );
m_water.endFill(); // Works for basic arrowhead shape
Using the exact same technique, I have this problem when I try to fill an enclosed sine wave / rect:
I don’t want to force anyone who uses this graphics library to split their dynamic drawing into separate parts, I would expect drawPolygon to correctly fill in any polygon without filling outside the lines.
Remember, this library is for educational purposes, for children some as young as 12, these function needs to work how you would expect it to work.
Is there an easy hack / fix for this which I can add to my graphics library without having to change the usage of these 5 graphics functions, or do I have to post this as an official bug?
Thanks, I really appreciate any help I can get on this.