Squeak magic

karl karl.ramberg at comhem.se
Tue Jun 5 18:08:22 UTC 2007


subbukk wrote:
> Hi,
>
> Please try opening the attached gif in a photo/image viewer - it is just a 
> translucent rotated rectangle. Now import the attached gif into Squeak. Does 
> a bluish background appear behind the rotated rectangle? On notebooks, tilt 
> the screen forward to see it clearly. When looking at it directly, the blue 
> background appears to fade in and fade out as you move the morph from top to 
> bottom.
>
> It is all Squeak magic :-). The magic works on Squeakland plugin, 3.9 and 3.10 
> images on Linux (3.7-7) and Mac VMs (3.8). I don't know if Win32 VMs also 
> show the same effect. Can someone confirm, please? Thanks.
>
> The gif was produced from a rotated rounded rectangle in Squeak 3.9 after 
> filing in the patches in
>  http://bugs.squeak.org/view.php?id=2241

Look at this thread:
http://lists.squeakfoundation.org/pipermail/squeak-dev/2006-December/112133.html

The right BitBlt rules are not implemented in Squeak so problems occur.

Test the attached change set to see if the problem is still there.
Karl
-------------- next part --------------
'From OLPC2.0 of ''24 October 2006'' [latest update: #1358] on 5 June 2007 at 8:02:47 pm'!
"Change Set:		FormTranslucency
Date:			17 December 2006
Author:			Karl Ramberg

Project to make translucency work in different screen resolutions and with rotated morphs "!


!Canvas methodsFor: 'drawing-images' stamp: 'k 6/5/2007 19:37'!
translucentImage: aForm at: aPoint sourceRect: sourceRect
	"Draw a translucent image using the best available way of representing translucency.
	Note: This will be fixed in the future."
	| multipliedForm |
	self shadowColor ifNotNil:[
		^self stencil: aForm at: aPoint sourceRect: sourceRect color: self shadowColor].
	((self depth < 32 and:[aForm depth = 32]) and:[self depth > 4])
		ifTrue:[ 
    "Convert aForm to pre-multiplied"
    multipliedForm := Form extent: aForm extent depth: 32.
    aForm displayOn: multipliedForm at: 0 @ 0 rule: Form blend.
    ^self image: multipliedForm at: aPoint sourceRect: sourceRect rule: 34].
	(self depth < 32 or:[aForm isTranslucent not]) 
		ifTrue:[^self paintImage: aForm at: aPoint sourceRect: sourceRect].
	self image: aForm
		at: aPoint
		sourceRect: sourceRect
		rule: Form blend! !


!FormCanvas methodsFor: 'drawing-support' stamp: 'k 6/5/2007 19:53'!
transformBy: aDisplayTransform clippingTo: aClipRect during: aBlock	 smoothing: cellSize

	"Note: This method has been originally copied from TransformationMorph."
	| innerRect patchRect sourceQuad warp start subCanvas |
	(aDisplayTransform isPureTranslation) ifTrue:[
		^aBlock value: (self copyOffset: aDisplayTransform offset negated truncated
							clipRect: aClipRect)
	].
	"Prepare an appropriate warp from patch to innerRect"
	innerRect _ aClipRect.
	patchRect _ (aDisplayTransform globalBoundsToLocal: innerRect) truncated.
	sourceQuad _ (aDisplayTransform sourceQuadFor: innerRect)
					collect: [:p | p - patchRect topLeft].
	warp _ self warpFrom: sourceQuad toRect: innerRect.
	warp cellSize: cellSize.

	"Render the submorphs visible in the clipping rectangle, as patchForm"
	start _ (self depth = 1 and: [self isShadowDrawing not])
		"If this is true B&W, then we need a first pass for erasure."
		ifTrue: [1] ifFalse: [2].
	start to: 2 do:
		[:i | "If i=1 we first make a shadow and erase it for opaque whites in B&W"
		subCanvas _ self class extent: patchRect extent depth: self depth.
		i=1	ifTrue: [subCanvas shadowColor: Color black.
					warp combinationRule: Form erase]
			ifFalse: [self isShadowDrawing ifTrue:
					[subCanvas shadowColor: self shadowColor].
					(self depth = 32) ifTrue:[warp combinationRule: 34]
					ifFalse:[warp combinationRule: Form paint]].
		subCanvas translateBy: patchRect topLeft negated
			during:[:offsetCanvas| aBlock value: offsetCanvas].
		warp sourceForm: subCanvas form; warpBits.
		warp sourceForm: nil.  subCanvas _ nil "release space for next loop"]
! !



More information about the Squeak-dev mailing list