Thanks for quick reply.

> Rr = (Sr > Dr) ? Sr : Dr
> Rg = (Sg > Dg) ? Sg : Dg
> Rb = (Sb > Db) ? Sb : Db

Yes, that's what I want. After giving it another thought, I see that
it's not equivalent to bitwise OR, say MAX (1,2) = 2, wheres OR (1,2)
= 3.

Anyway, I would like to know if it's possible to use the MAX
compositing operation (this time I need MAX, but maybe I will also
need other, such as MIN, OR, AND, NOT, whatever). I have checked all
values of NSCompositingOperation, but haven't found what I need. They
all seem to be dealing with transparency mostly, not with color
values.

Any ideas?

Here's where I found this problem. I'm implementing a cross-fade
animation of text. One string fades out, and another string fades in
at the same time. The problem is that in areas where the text glyphs
from the two strings overlap, the sum of colors results in brighter
pixels than each of the strings taken separately. This results in an
annoying flash of brighter color in the middle of the animation. I'd
like to fix it by limiting the brightness of all pixels by the value
of the text color.


On Tue, Sep 22, 2009 at 4:58 PM, Colin Howarth <co...@howarth.de> wrote:
> On 22 Sep, 2009, at 15:22, Oleg Krupnov wrote:
>
>> Hi,
>>
>> I'd like to draw in a graphics context in such a compositing mode:
>>
>> R = MAX(S, D)
>>
>> i.e. out of two colors (source and destination), the maximum color
>> (channel-wise) was chosen. This is basically equivalent to ORing the
>> colors.
>>
>> Is this possible? I don't see such NSCompositingOperation. There's
>> only NSCompositeXOR, but no NSCompositeOR...
>
>
> I'm not quite sure what you mean by "maximum color (channel-wise)".
> Do you mean
>
> Rr = (Sr > Dr) ? Sr : Dr
> Rg = (Sg > Dg) ? Sg : Dg
> Rb = (Sb > Db) ? Sb : Db
>
>
>
> A quick google threw up http://my.safaribooksonline.com/0672322307/ch14
> for the compositing operations. The logic operation XOR appears to be binary
> (opaque/transparent). It might be that what you want is simply called
> something
> else (like NSCompositeSourceOver).
>
>
>
> A long time ago I remember XORing pixels D' = (S XOR D) changed the colour
> and (S XOR D')
> changed it back again. But that was bitwise XOR, ie.
>
> Rr0 = Sr0 XOR Dr0
> Rr1 = Sr1 XOR Dr1
> ...
> etc.
>
>
>
> And finally, mathematically,   A OR B = (A XOR B) XOR (A AND B)
>
>
>
>
> I wonder if any of that helps?  :-)
>
>
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to