Squeak magic

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Squeak magic

K. K. Subramaniam
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

Some bugs are really fun .. Subbu



alphaError.gif (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Squeak magic

Karl-19
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

'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"]
! !



Reply | Threaded
Open this post in threaded view
|

Re: Squeak magic

K. K. Subramaniam
On Tuesday 05 June 2007 11:38 pm, karl wrote:
> 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.
The patch is not visible over white or (r:0.8, g:1.0, b:1.0) (e.g. Ruler) with
your change set. However, if I drag the rotated morph over a ScrollingText  
(r:0.972 g: 972, b: 0.662), it is clearly visible. The attached st file when
loaded on 3.9/3.10 +your cs will reveal this problem. Translucency is also
lost when looked through a HandMagnifier.

Since it is so sensitive to colors, would round off errors in color
calculations be the root cause?

Regards .. Subbu



testRotate.st (166 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Squeak magic

Karl-19
subbukk wrote:

> On Tuesday 05 June 2007 11:38 pm, karl wrote:
>  
>> 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.
>>    
> The patch is not visible over white or (r:0.8, g:1.0, b:1.0) (e.g. Ruler) with
> your change set. However, if I drag the rotated morph over a ScrollingText  
> (r:0.972 g: 972, b: 0.662), it is clearly visible. The attached st file when
> loaded on 3.9/3.10 +your cs will reveal this problem. Translucency is also
> lost when looked through a HandMagnifier.
>
> Since it is so sensitive to colors, would round off errors in color
> calculations be the root cause?
All the magic happens in the BitBlt plugin. The problem is that the
rules to preserve translucency in rotation are not implemented so what
my change set does is cheat by using an other rule, which give the color
change.

karl