Question about flushing Display on Canvas

Milan Zimmermann milan.zimmermann at sympatico.ca
Mon May 2 02:43:08 UTC 2005


On May 1, 2005 05:33 pm, Bert Freudenberg wrote:
> 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>
<<snip>>
>
> 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.


Thanks, I tried this, but do not really want to draw on the "basic display" 
(not sure about the correct name) as it draws on the whole world. Obviously I 
do not know about the way Squeak graphic works, this is one part of my small 
project which I use to learn Smalltalk. I should have explained what I am 
trying to achieve: 

I am trying to draw (lines, rectangles etc) onto some object that I could 
manipulate in world as a window or a morph (which would provide clipping as 
well). The only way I found to do this is to draw on a Canvas inside a form, 
but obviously failing to make the Canvas changes to tell the container how to 
refresh (I am sure my terminology is wrong too)

I tried to search the Swiki for code examples to do this, but did not get far 
enough ... so far,

Thanks Milan

>
>
> - Bert -




More information about the Squeak-dev mailing list