drawBezierShape in drawOn

Bert Freudenberg bert at impara.de
Wed Dec 7 19:43:11 UTC 2005


Am 07.12.2005 um 18:55 schrieb TJ Leone:

> Squeakers,
>
> I finally got back to looking at Squeak, and I have my first dumb  
> question.
>
> I tried to make a class called AMorph (subclass of Morph) with the  
> following drawOn method:
>
> ---------------------------------------------------------------------- 
> --------
> drawOn: aCanvas
>
>         "draw a Bezier shape"
>
>         aCanvas asBalloonCanvas aaLevel: 4;
>         drawBezierShape: {30 @ 30. 30 @ 200. 200 @ 10.
>                          200 @ 10. 50 @ 150.  50 @ 30.
>                           50 @ 30. 30 @ 30.   30 @ 30}
>         color: Color red
>         borderWidth: 1
>         borderColor: Color green
> ---------------------------------------------------------------------- 
> -----------
>
> To get it to draw I execute the following in a Workspace:
>
> AMorph new openInWorld.
>
> After overwriting defaultBounds, the shape draws fine, but it  
> disappears when I drag it around and try to drop anywhere besides  
> the upper left corner of the World.
>
> It looks like I need to do something to tell AMorph that the  
> control points should be relative to its position, but I'm not sure  
> how to that.  How do I fix this method?

	aCanvas asBalloonCanvas
		aaLevel: 4;
		translateBy: bounds origin
		clippingTo: bounds
		during: [:cc | cc
				drawBezierShape: {30 @ 30. 30 @ 200. 200 @ 10. 200 @ 10. 50 @  
150. 50 @ 30. 50 @ 30. 30 @ 30. 30 @ 30}
				color: Color red
				borderWidth: 1
				borderColor: Color green]



- Bert -




More information about the Squeak-dev mailing list