[squeak-dev] ImageForm color with alpha
marcel.taeumel at hpi.de
Tue Dec 11 08:08:26 UTC 2018
Hmm... according to Canvas >> #translucentImage:at:sourceRect: and FormCanvas >> #setFillColor: (via FormCanvas >> #frameAndFillRectangle:...) both use "Form blend".
It should produce the same result.
Maybe the Form (via #imageForm) itself is created differently. See Morph >> #imageForm:forRectangle: and FormCanvas >> #transformBy:clippingTo:during:smoothing:.
There are only two senders of #blendAlphaScaled.
Am 11.12.2018 09:00:36 schrieb Stéphane Rollandin <lecteur at zogotounga.net>:
> Why is it that
> (Morph new color: (Color blue alpha: 0.5))
> (Morph new color: (Color blue alpha: 0.5)) imageForm asMorph
> do not have the same color?
> Because ImageMorph is using "Form blend" rule instead of "Form
Where does this happen? Using SketchMorph instead of ImageMorph shows
the same behavior.
The only way I found so far to fix the issue is to subclass FormCanvas
as FormCanvas2, with the single method #setFillColor: where I changed
the #blend send to #blendAlpha, and then to redefine
#imageForm:forRectangle: in Rectangle as
imageForm: depth forRectangle: rect
| canvas |
canvas := FormCanvas2 extent: rect extent depth: depth.
canvas translateBy: rect topLeft negated
during:[:tempCanvas| tempCanvas fullDrawMorph: self].
^ canvas form offset: rect topLeft
(see attached code)
Is there another way to have a Form exactly faithful to the displayed
morph? And shouldn't that be the defaut behavior of #imageForm (in other
words, isn't the current behavior a bug)?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Squeak-dev