Hello all,
Why is it that (Morph new color: (Color blue alpha: 0.5)) and (Morph new color: (Color blue alpha: 0.5)) imageForm asMorph do not have the same color? Stef |
On Mon, Dec 10, 2018 at 3:36 AM Stéphane Rollandin <[hidden email]> wrote: Hello all, Because ImageMorph is using "Form blend" rule instead of "Form blendAlphaScaled". - Bert - |
>
> Why is it that > > (Morph new color: (Color blue alpha: 0.5)) > > and > > (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 > blendAlphaScaled". 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)? Best, Stef Morph-imageFormforRectangle.st (558 bytes) Download Attachment FormCanvas2.st (2K) Download Attachment |
Hi, there. 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. Best, Marcel
|
> 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. Ah! It seems that simply using #blendAlphaScaled in #translucentImage:at:sourceRect: does the trick... Stef |
> Ah! It seems that simply using #blendAlphaScaled in
> #translucentImage:at:sourceRect: does the trick... Unfortunately this has side effects. For example, #dimmed is now broken... Stef |
Hmm... that's not good for an arbitrary form with alpha informationen. Why not use #blend the entire time here? Isn't #blendAlpha and #blendAlphaScaled kind of a performance trick? blend "Answer the integer denoting BitBlt's alpha blend combination rule." ^24 blendAlpha "Answer the integer denoting BitBlt's blend-with-constant-alpha rule." ^ 30 blendAlphaScaled "Answer the integer denoting BitBlt's blend-with-alpha-scaled rule." ^ 34 Best, Marcel
|
Free forum by Nabble | Edit this page |