Linear Alpha Blending
Linear Alpha Blending
- Subject: Linear Alpha Blending
- From: Jeff McClintock via Cocoa-dev <email@hidden>
- Date: Wed, 11 Oct 2023 12:48:55 +1300
Hi,
I am drawing user-interface elements in Cocoa. I have a problem with
transparent colors.
I have created a minimal example to illustrate the issue.
https://github.com/JeffMcClintock/AlphaBlender
Here is the apps output:
https://synthedit.com/files/AlphaBlender.png
To explain, the app is drawing (left to right) first some solid colors (White,
Black, 50% Grey), then a checkerboard pattern (50% white, 50% black), then two
blends – 50% white over Black and 50% black over white.
My aim is that any blend of two colors is calculated in a linear RGB color
space. So ideally all 3 shades on the right would appear to be the same
brightness as the checkerboard (a physical brightness half way between black
and white).
I think, based on the sRGB curve that the raw pixel brightness of mid-grey is
188 (on a scale of 0 – 255) i.e. hex 0xBCBCBC. This is the pixel value that I
am hoping to achieve with a 50% blend of black and white.
I have tried creating the NSColor with various different colorspaces, but this
seems to not affect the result of the blending.
Any suggestions of how I can achieve this are appreciated!
Jeff
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden