Question about flushing Display on Canvas

Bert Freudenberg bert at impara.de
Sun May 1 21:33:40 UTC 2005


Am 01.05.2005 um 19:54 schrieb Milan Zimmermann:

> Hi,
>
> I am trying to paint (draw lines) on Canvas from workspace. I use:
>
> aDrawingForm := Form extent: 400 at 600 depth: Display depth.
> aCanvas := aDrawingForm getCanvas.
> aCanvas fillColor: (Color yellow).
> aDrawingForm asMorph openInWorld.
> <Alt-d>
>
> This shows yeallow canvas. Then I do
>
> aCanvas line: 10 at 10 to: 50 at 30 width: 3 color: (Color black).
> aCanvas flush.
> <Alt-d>
>
> I expected the line to be shown immediately but it only happens  
> when I either
> click on or move the Canvas. I tried "aCanvas flushDisplay" and  
> "aCanvas
> forceToScreen: rect" but both behave the same.
>
> Is there a way to force a refresh after drawing on Canvas?  
> (Perhaps  I should
> not expect this to work this way and use another method for drawing  
> from?)

What your code does is draw into the form of an ImageMorph. Of  
course, the Morph does not know that you modified the form. So it  
does not repaint itself (that is, copy its form to the Display). It  
does redisplay when you move it, however.

I'm not sure what you're actually trying to achieve. If you want to  
draw directly to the display, then use

     aCanvas := Display getCanvas.


- Bert -




More information about the Squeak-dev mailing list