[squeak-dev] Re: Morph shadows

Chris Muller asqueaker at gmail.com
Thu Dec 10 16:14:38 UTC 2009


Thanks for your help.  I think I've made progress, but still have not
cracked the nut.  My morph responds false to #wantsToBeCachedByHand,
it has lots of translucent color in it.  Just to reiterate, I'm
blitting a transparent raster image with many translucent data-points
to a *particular size/position* on the Display FormCanvas that comes
into #drawOn:.

Overriding wantsToBeCachedByHand to true did not help, however, if I
change the last line of HandMorph>>#shadowForm to NOT set the #offset:
of the returned (shadow) Form, the shadow does seem to render and
track properly with the drawn morph _as long as_ it's within the
upper-left of the screen (seemingly within the upper-left bounds of
the extent of the Morph).  But the shadow is completely absent when
dragged out to the middle of the screen..

Another clue:  Rotation is not working.  When I rotate, the rendering
of my blitted Form seems to disappear entirely (surely being drawn way
out somewhere else).

I think my problem has something with the Form>>'offset'.  In my
#drawOn:, I tried changing the bit-blit to set MY (scaled) data-form's
#offset to the upper-left of where I normally draw it, and telling it
to draw at 0 at 0 instead.  Specifically, changed my code FROM:

paintFor: aKmlPainter
	| canvasBounds |
	super paintFor: aKmlPainter.
	aKmlPainter form == form ifFalse:
		[ (aKmlPainter clipRect intersects: (canvasBounds := self
surfaceBounds geoToCanvasFor: aKmlPainter)) ifTrue:
			[ (form scaledToSize: (canvasBounds extent))
				displayOn: aKmlPainter form
				at: (canvasBounds topLeft)
				clippingBox: canvasBounds
				rule: Form blend
				fillColor: nil ] ]

TO:

paintFor: aKmlPainter
	| canvasBounds |
	super paintFor: aKmlPainter.
	aKmlPainter form == form ifFalse:
		[ (aKmlPainter clipRect intersects: (canvasBounds := self
surfaceBounds geoToCanvasFor: aKmlPainter)) ifTrue:
			[ (form scaledToSize: (canvasBounds extent))
offset: canvasBounds topLeft ;      <---------------------------------- added
				displayOn: aKmlPainter form
				at: (0 at 0)    <---------------------------------- changed
				clippingBox: canvasBounds
				rule: Form blend
				fillColor: nil ] ]

I'm sorry, I can't really make out what Form>>#offset is for; I'm not
finding many helpful comments about it.

My other "standard" drawing, lines and polygons, etc., directly onto
the Display FormCanvas is all working fine, including rotation.  It's
just this part that is bit-blitted onto the Display FormCanvas..

Thank you,
  Chris


On Tue, Dec 8, 2009 at 5:41 PM, Andreas Raab <andreas.raab at gmx.de> wrote:
> Chris Muller wrote:
>>
>> Would someone point me to the code that renders the shadow drawn when
>> a Morph is picked up?  My #drawOn: involves bit-blitting a separate
>> scaled Form onto a particular region of the Display Canvas that comes
>> into drawOn:.
>>
>> The shadow made of this form is not tracking properly with the picked
>> up morph; it slides out further and further wider and lower as I move
>> down and to the right.
>>
>> Any advice would be appreciated.
>
> Check out Morph>>wantsToBeCachedByHand this may be your problem already
> (have it return true to make sure the hand isn't having some undue
> assumptions about how to cache that morph). The actual drawing happens in
> HandMorph>>updateCacheCanvas: / HandMorph>>shadowForm depending on whether
> it uses caching or not.
>
> Cheers,
>  - Andreas
>
>



More information about the Squeak-dev mailing list