Hi Joe,

the problem is that the BalloonCanvas (or some objects it is using) aren't
fully reset after some drawing operations.
(the drawString method for example sets the sourceForm as glyph to be
drawn).

it should work if you do not store the canvas instance, but create a new in
every loop:

    points do: [ :p |

       canvas := form getCanvas asBalloonCanvas aaLevel:4; yourself.

       canvas drawPolygon: p
          color: Color transparent
          borderWidth: 1
          borderColor: Color red.

       canvas drawString: p first asString
          at: p first
          font: nil
          color: Color green.
    ].




Or just reset the engine state (but I don't like this solution, the engine
state should be private to the canvas).

    points do: [ :p |

       canvas drawPolygon: p
          color: Color transparent
          borderWidth: 1
          borderColor: Color red.

       canvas drawString: p first asString
          at: p first
          font: nil
          color: Color green.
       canvas resetEngine.
    ].





2018-04-06 2:57 GMT+02:00 <j...@boremaj.net>:

> Hello everyone!
>
> Im trying use the balloon canvas to draw some nice smooth anti aliased
> lines, but now i seem to have hit upon a bug which i dont know how to fix.
>
> if i draw just lines i get everything i want.  but if i add a
> “drawString:…” in there at any point, all the lines i try to draw
> subsequently dont show up.
>
> Here is code that shows the exact issue:
>
> form := Form extent: 100@100 depth: 32.
> form fillWhite.
> canvas := BalloonCanvas on: form.
> canvas aaLevel: 4.
> "canvas := FormCanvas on: form."
> points := { {10@10 . 50@43} . {50@42 . 90@75} . {90@75 . 50@90 } }.
>
> points do: [ :p |
>    canvas drawPolygon: p
>       color: Color transparent
>       borderWidth: 1
>       borderColor: Color red.
>
>    canvas drawString: p first asString
>       at: p first
>       font: nil
>       color: Color green.
> ].
>
> morph := ImageMorph new.
> morph image: form.
> morph openCenteredInWorld.
>
>
>
> if i comment out the canvas drawstring i get what you would expect: a
> squiggly line.
>
> if i add in the drawstring, the first line shows up but all the subsequent
> lines do not get drawn.  (both images attached)
>
> I spent a bunch of time tracking it down to its most purest form and then
> a bunch of time debugging it and im out of my depth with the baloon code, i
> cant seem to figure out whats wrong.  if anyone knows whats wrong or can
> give me a clue on how to fix it i’d greatly appreciate it.
>
> thanks in advance.
>
>
> { jb }
>

Reply via email to