Keyhole effect?

Mark Waddingham mark at livecode.com
Wed Apr 15 04:27:37 EDT 2020


On 2020-04-15 02:30, Richard Gaskin via use-livecode wrote:
> Monte Goulding wrote:
> 
>> If I understand what you want correctly then:
>> 
>> Create image
>> Create mask object
>> Group both
>> Set the ink of the mask object to blendDstIn
>> Set the ink of the group to blendSrcOver
> 
> Super, Monte. That works well.
> 
> I was up late with a tool I'd made to let me walk through all sorts of
> combinations, but I hadn't thought to group them.

Oh look, clearly the 'useful' inks haven't really been removed - they've 
just been replaced with the modern equivalents which give much better 
fidelity results ;)

Just to explain why the group is necessary - if a group has the 
'blendSrcOver' ink applied then it becomes a 'transparency group'.

This means it has its own alpha channel which can be affected by the 
'destination alpha modifying' porter-duff operations. So in this case:

   1) The group is a transparency group so allocates its own transparent 
buffer
   2) The image is composited into the buffer
   3) The mask is then composited into the buffer with the DstIn ink. 
This means that the destination buffer alpha is adjusted so it is only 
'in' the mask (an analog of ANDing the buffers alpha channel with the 
mask's alpha channel - indeed, previously I'm guessing you would have 
done this using some sort of AND bitwise ink and being careful with 
colors used).
   4) The buffer is then composited with the background.

The transparency group thing is needed partly for efficiency and partly 
because you can't remove alpha from an opaque destination - which a 
window provides.

Hope this helps!

Mark.

-- 
Mark Waddingham ~ mark at livecode.com ~ http://www.livecode.com/
LiveCode: Everyone can create apps




More information about the use-livecode mailing list