[Q][balloon2D] is transparency supported?

Baveco, Hans Hans.Baveco at wur.nl
Sun Feb 27 21:48:31 UTC 2005


Thanks Ned,
I have it all working now and will hopefully soon be able to put a simple shape-file viewer on squeakmap.
I am still a bit confused on how to work with Canvasses, but apparently it is simpler than I thought it was.
(the GraphicsContext in VisualWorks has also been hard to grasp for me...).
 
Hans
 

	
	
	 

	On Friday 25 February 2005 1:41 pm, Hans Baveco wrote:
	> To illustrate my problem, compare the result of the two code fragments, the
	upper one provided by Boris, the second one illustrating what I have been
	doing. I would really like to have the result of the first fragment, but not
	on the Display but on a morph...
	[snip]
	> >   fs direction: 600 at 300.
	>   fs radial: false.
	>   bc := BalloonCanvas on: form "Display" .
	>   bc aaLevel: 2.
	>   bc drawPolygon: (Array with: 10 at 10 with: 500 at 300 with: 300 @500 with: 50
	> @ 300) fillStyle: fs
	>      borderWidth: 2
	>      borderColor: ((Color red) alpha: 0.3).
	>  ^form asMorph openInWorld
	
	
	The problem is that "form asMorph" makes a Morph that doesn't know how to be
	translucent. Look at ImageMorph>>drawOn:
	
	drawOn: aCanvas
	 | style |
	 (style _ self borderStyle) ifNotNil:[
	  style frameRectangle: bounds on: aCanvas.
	 ].
	 self isOpaque
	  ifTrue:[aCanvas drawImage: image at: self innerBounds origin]
	  ifFalse:[aCanvas translucentImage: image at: self innerBounds origin]
	
	So what's the definition of isOpaque?
	
	I don't understand, though, what the distinction between "on the Display" and
	"on a morph" is.
	
	From the graphical point of view, all a Morph does is to draw itself on
	canvases when asked.
	
	So all you need to do is:
	
	drawOn: aCanvas
	 aCanvas asBalloonCanvas drawPolygon: ...
	
	or something similar.
	
	As long as "asBalloonCanvas" returns a BalloonCanvas (which FormCanvas does),
	you get the same thing whether the Morph is being rendered to the Display, to
	a form, or is being rendered some other way.
	
	However, because some canvases (notablly the ShadowCanvas used to draw drop
	shadows) don't actually respond to asBalloonCanvas, or return a BalloonCanvas
	when asked, you have to be a little more careful sometimes: either you stick
	to the guaranteed Canvas operations, or you test for whether you got a canvas
	that supports your desired operations. In Connectors (which sometimes draw
	themselves using Bezier curves) I had to test the resultant canvas and use a
	different drawing strategy for shadows.
	
	--
	Ned Konz
	http://bike-nomad.com/squeak/
	



More information about the Squeak-dev mailing list