I’m trying to draw multiple shapes in the same Sprite.graphics scope, and can’t seem to find any reasonable solution to my problem.
Please keep in minde that I’ve been using the drawPath() method for a performance problem : I could use multiple shapes with blendmodes, but I’d like to avoid that and keep performances cost to the minimum.
I’ve been experimenting with the winding parameter of the drawPath() method, but one thing that I cannot understand, is how the winding direction is defined by Flash, so here is a first question before actually coming to the real problem :
Are points coordinates taken in account ? Or is it the angle between the produces lines that define the direction ?
That being said, here is my actual problem :
I want to draw a shape that is a projection from a rectangle on a line – think of a window and the light that passes through it that goes hit the floor.

To achieve that, I must take into account that the lightsource position can vary and have that kind of results :

Here on that second picture you can already see the problem I’m facing.
To draw my shape, I’ve been separately “drawing” (understand : placing the numbers in my coordinates vector) the different parts of my figure : the actual rectangle I want to project, the light projected from its left side, the light projected from its bottom side, and the light projected from its right side.
I’ve been trying to carefully keep the winding direction the same in every section, beginning from the top-left corner, but it seems something is wrong in my reasoning, since every time the center part overlaps with any side part, the shape is emptied there, and every time the two sides parts overlaps, the same happens.
As I’m writing that here, some revelation suddenly strike me, and now I guess that maybe ALL my points in my coordinates vector must be sorted in the same winding direction for my shape to work ?… (and not only the small parts I’m separately drawing in my mind ^^)
If I’m right (please correct me if I’m not, or if I’ve understood anything wrong ?…), that means I must either :
-
sort my points to be placed in the correct winding direction (thing that might be complicated and could result in some strange drawed shape once provided to the drawing API ?…)
-
only draw the shape from the most external points, depending on the shape’s actual shape (thing that might be more complicated that I currently expect).
Could anyone here confirm or infirm my last suppositions, and give me a clue on what could be going on here and how to solve it ?…
Thanks a lot 🙂
You want to have one shape composed out of three projector lines? Okay, you have determined the positions of two lower points, and you have 4 points of your window. You then construct a list like so:
You’re done. And you will no longer need 3 projections, you calculate only the bottommost one (it’ll give you both points on the floor), and make your list. Should do. Please comment.