From:  ron VS <ronvs1@gmail.com>
Date:  22 Jul 2009 18:05:17 Hong Kong Time
Newsgroup:  news.mozilla.org/mozilla.dev.web-development
Subject:  

Question on Alpha behavior for canvas

NNTP-Posting-Host:  131.170.90.2

Hi,

I see in content/canvas/test/test_2d.composite.transparent.xor.html
the following code:

ctx.fillStyle = 'rgba(0, 255, 0, 0.5)';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'xor';
ctx.fillStyle = 'rgba(0, 0, 255, 0.75)';
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 50,25, 0,63,191,127, "50,25", "0,63,191,127", 5);

By my reckoning, without using alpha, we have:
R = 0 xor 0 = 0
G = 255 xor 0 = 255
B = 0 xor 255 = 255
so the result should be 0,255,255,

With alpha, I think we get
R = 0.5*0 xor 0.75*0 = 0 xor 0 = 0
G = 0.5*255 xor 0.75*0 = 127 xor 0 = 127
B = 0.5*0 xor 0.75*255 = 0 xor 191 = 191

but isPixel says 0, 63,191.127

Where did the 63 come from?
Or if 127 is combined with 63 (=127), then why not for the 191?

Cheers, Ron