Question about flushing Display on Canvas

Milan Zimmermann milan.zimmermann at sympatico.ca
Thu May 5 04:48:27 UTC 2005


Thanks Lex,

I ended up with only one class #DrawingCanvs extension of PluggableCanvas,  
because I was unable to control background and extent of the DrawingMorph in 
the time I gave it.

In a way, for someone who tries drawing for the first time, it's quite 
difficult to "get" because there are 3 classes involved: Form, Morph, Canvas:
=========
	form := Form extent: 400 at 600 depth: Display depth.
	canvas := form  getCanvas.
	canvas fillColor: (Color yellow).
	morph := form asMorph openInWorld.
	canvas line: 10 at 10 to: 50 at 30 width: 3 color: (Color red).
	morph changed.
	...
==

It would really be nice to have a Morph where one could do:
=========
	morph := NiceDrawingMorph new extent: 200 at 200 background: Color yellow.
	morph line:5 at 5 to: 30 at 30 width: 5 color:(Color green).
	...
==
Which is close to what Bert's class allows. To me it is natural to override 
#drawOn: but the way it's using Blocks requires getting used to (for me)....

I thought another decent way was to have 2 "intertwined" classes #DrawingMorph 
and #DrawingCanvas, which I tried to do, and use it as:
=========
	drawingMorph := DrawingMorph new openInWorld.
	drawingCanvas := drawingMorph getDrawingCanvas.
	drawingCanvas line:5 at 5 to: 30 at 30 color:(Color red).
	...
==
This worked "in principle" but I was unable to control the extents and 
background ...

So I ended up with just #DrawingCanvas extension of PluggableCanvas, which 
refreshes without explicit #changed, but with the caveat of the old unwieldy 
use through 3 classes:
=========
	form := Form extent: 400 at 400 depth: Display depth.
	canvas := form getCanvas.
	morph := form asMorph openInWorld.
	drawingCanvas := DrawingCanvas createFromMorph: morph withCanvas: canvas.
	drawingCanvas fillColor: (Color yellow).
	drawingCanvas line:5 at 5 to: 30 at 30 color:(Color red).
	...
==

Thanks for your help. BTW I am trying to use line drawing in my project that I 
use to learn Smalltalk .. slowly (animate a 3D Surface built as Mesh).

Thanks again Milan

I am curious how drawing like this would be different in Tweak if any, need to 
do some homework on it later ...

On May 4, 2005 09:45 am, Lex Spoon wrote:
> Looks beautiful, Milan!
>
>  -Lex




More information about the Squeak-dev mailing list