line drawing bug

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
12 messages Options
joe
Reply | Threaded
Open this post in threaded view
|

line drawing bug

joe
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 }

correct-no-strings.png (6K) Download Attachment
incorrect-with-strings.png (8K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: line drawing bug

HilaireFernandes
I don't think anybody within Pharo use the balloon canvas. You should
ask to the Squeak community, you will very likely have more support on
that matter.

Hilaire


Le 06/04/2018 à 02:57, [hidden email] a écrit :
> 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.
>

--
Dr. Geo
http://drgeo.eu



Reply | Threaded
Open this post in threaded view
|

Re: line drawing bug

HilaireFernandes
I tried on a recent Squeak system, still got a buggy out put but a bit
surprisingly different!

Hialire


Le 06/04/2018 à 12:10, Hilaire a écrit :
> I don't think anybody within Pharo use the balloon canvas. You should
> ask to the Squeak community, you will very likely have more support on
> that matter.

--
Dr. Geo
http://drgeo.eu



Reply | Threaded
Open this post in threaded view
|

Re: line drawing bug

EstebanLM
hi,

real question is why you use Balloon and not Athens :)

cheers,
Esteban

> On 6 Apr 2018, at 12:14, Hilaire <[hidden email]> wrote:
>
> I tried on a recent Squeak system, still got a buggy out put but a bit surprisingly different!
>
> Hialire
>
>
> Le 06/04/2018 à 12:10, Hilaire a écrit :
>> I don't think anybody within Pharo use the balloon canvas. You should ask to the Squeak community, you will very likely have more support on that matter.
>
> --
> Dr. Geo
> http://drgeo.eu
>
>
>


Reply | Threaded
Open this post in threaded view
|

Re: line drawing bug

Marcus Denker-4
And the real^2 question: why do we still have balloon in the image if we should not use it?

> On 6 Apr 2018, at 12:31, Esteban Lorenzano <[hidden email]> wrote:
>
> hi,
>
> real question is why you use Balloon and not Athens :)
>
> cheers,
> Esteban
>
>> On 6 Apr 2018, at 12:14, Hilaire <[hidden email]> wrote:
>>
>> I tried on a recent Squeak system, still got a buggy out put but a bit surprisingly different!
>>
>> Hialire
>>
>>
>> Le 06/04/2018 à 12:10, Hilaire a écrit :
>>> I don't think anybody within Pharo use the balloon canvas. You should ask to the Squeak community, you will very likely have more support on that matter.
>>
>> --
>> Dr. Geo
>> http://drgeo.eu
>>
>>
>>
>
>


Reply | Threaded
Open this post in threaded view
|

Re: line drawing bug

NorbertHartl


> Am 06.04.2018 um 12:58 schrieb Marcus Denker <[hidden email]>:
>
> And the real^2 question: why do we still have balloon in the image if we should not use it?
>
+1

Norbert

>> On 6 Apr 2018, at 12:31, Esteban Lorenzano <[hidden email]> wrote:
>>
>> hi,
>>
>> real question is why you use Balloon and not Athens :)
>>
>> cheers,
>> Esteban
>>
>>> On 6 Apr 2018, at 12:14, Hilaire <[hidden email]> wrote:
>>>
>>> I tried on a recent Squeak system, still got a buggy out put but a bit surprisingly different!
>>>
>>> Hialire
>>>
>>>
>>> Le 06/04/2018 à 12:10, Hilaire a écrit :
>>>> I don't think anybody within Pharo use the balloon canvas. You should ask to the Squeak community, you will very likely have more support on that matter.
>>>
>>> --
>>> Dr. Geo
>>> http://drgeo.eu
>>>
>>>
>>>
>>
>>
>
>


Reply | Threaded
Open this post in threaded view
|

Re: line drawing bug

HilaireFernandes
In reply to this post by EstebanLM
Does { jb } want to deploy on tablet computer (Android or iOS) ?


Le 06/04/2018 à 12:31, Esteban Lorenzano a écrit :
> real question is why you use Balloon and not Athens:)

--
Dr. Geo
http://drgeo.eu



Reply | Threaded
Open this post in threaded view
|

Re: line drawing bug

Nicolai Hess-3-2
In reply to this post by joe
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 <[hidden email]>:
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 }

joe
Reply | Threaded
Open this post in threaded view
|

Re: line drawing bug

joe
In reply to this post by EstebanLM

I must have missed the deprecation warnings when i ran my code. 8).

Ill check out Athens, i don’t want to have to rewrite the entire application to support a new drawing backend. As a first step it would be great if i could render to an Athens canvas using the same API or something like it, but in my quick experiments I’ve had no luck. I’m sure I’m doing something wrong.

Is there any Athens tutorial documentation? All I’ve found is forum posts and videos and most of that stuff is quite old and there are a lot of broken links.


{ jb }

On Apr 6, 2018, 6:32 AM -0400, Esteban Lorenzano <[hidden email]>, wrote:
hi,

real question is why you use Balloon and not Athens :)

cheers,
Esteban

joe
Reply | Threaded
Open this post in threaded view
|

Re: line drawing bug

joe
In reply to this post by HilaireFernandes


No at least not right now.


{ jb }

On Apr 6, 2018, 8:11 AM -0400, Hilaire <[hidden email]>, wrote:
Does { jb } want to deploy on tablet computer (Android or iOS) ?


Le <a dir="ltr" href="tel:06/04/2018" x-apple-data-detectors="true" x-apple-data-detectors-type="telephone" x-apple-data-detectors-result="1">06/04/2018 à 12:31, Esteban Lorenzano a écrit :
real question is why you use Balloon and not Athens:)

--
Dr. Geo
http://drgeo.eu



joe
Reply | Threaded
Open this post in threaded view
|

Re: line drawing bug

joe
In reply to this post by Nicolai Hess-3-2

That worked, thank you so much! This helps me get running in the interim while i investigate how to use Athens.


{ jb }

On Apr 6, 2018, 9:31 AM -0400, Nicolai Hess <[hidden email]>, wrote:
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 <[hidden email]>:
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 | Threaded
Open this post in threaded view
|

Re: line drawing bug

Stephane Ducasse-3
Check the examples around Athens.

On Fri, Apr 6, 2018 at 4:48 PM,  <[hidden email]> wrote:

>
> That worked, thank you so much! This helps me get running in the interim
> while i investigate how to use Athens.
>
>
> { jb }
>
> On Apr 6, 2018, 9:31 AM -0400, Nicolai Hess <[hidden email]>, wrote:
>
> 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 <[hidden email]>:
>>
>> 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 }
>
>