On Mon, Mar 9, 2009 at 12:44 AM, xyloidhead <[email protected]> wrote:
> The mess of 3 continues, as does the incorrect function of 4. though 4
> is easier to see just try drawing a 45 degree line slowly.
>
>> 3) My initial code just added one line after another to the same
>> canvas but as more lines were added it got slower and slower, line
>> being drawn a long way behind the mouse. My solution was to create a
>> new draw canvas for every line.
>>
>> Now this works fine, or appears to but it seems untidy. Is there a
>> better way?
>>
The idea of a canvas is that it redraws itself after a change. So it
has to redraw a lot of lines if there are a lot of lines in the
canvas.
Connected lines should always be in the same canvas.(so we can try to
keep the joins without gaps)
Having many canvas seems expensive, but its what you expec canvas to
do for you transparently, so it cant be that bad.
And having canvas smart enough fro that is something i havent tried to
do yet, and maybe its not worth it. (its easy to do it when using
canvas and you have more information that canvas doesnt need to infer)
>> 4) Draw a few lines, preferably with shart direction changes, and
>> you'll see that there are gaps generated in either the endcaps or
>> discontinuities on the joins.
>>
Playing with your code i see that the problem is that draw wont draw a
join when the line length is too short. this shows the problem:
line_width = 50
self.set_color( (255,255,0,50) )
self.set_stroke_width( line_width )
self.set_join( draw.ROUND_JOIN )
self.move_to((100,100))
self.line_to((150,100))
self.line_to((150, 124))
If we increase the last 124 to 125 it will work.
The problem is that draw needs to cut 25 pixels from the second
segment to draw the join. but it doesnt have enough pixels, so it does
weird things.
It is a bug, and a very nasty one. A workaround would be to only add
lines is the movement is bigger than half the line width. ugly, i
know.
There are still issues with sharp turns.
Summing it up, cocos.Draw is not ready for prime time.
Lucio.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"cocos2d discuss" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/cocos-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---