Closed Bug 902246 Opened 11 years ago Closed 11 years ago

rgba + matte color conversion utility

Categories

(Firefox for Metro Graveyard :: General, defect)

x86_64
Windows 8
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED
Firefox 26

People

(Reporter: sfoster, Assigned: sfoster)

References

Details

Attachments

(1 file)

We have a need (in bug 895519 at minimum) to take a given color and calculate a lighter tint for coloring backgrounds. To-date we've done this using the alpha-channel against a white background, but this doesn't work if the color must be opaque. Converting to the HSV color space for the calculation seems the best bet? 

I'm proposing this should land in browser/metro/modules/colorUtils.jsm
Assignee: nobody → sfoster
Summary: rgba + matt to HSV color conversion utility → rgba + matte color conversion utility
Adds methods to add 2 colors together, and refactors a little to allow reuse of the code that goes to/from packed number data format. 
I've tacked on the alpha channel value to the existing 8/8/8 rgb "words", in a way that I hope is expected and not-surprising. The only gotcha with doing this is that there's no way to distinguish a fully-transparent color from one with no alpha channel (i.e. fully opaque). As a fully-transparent color is an edge case, I've elected to treat all falsey alpha values (0 or undefined) as opaque.
Attachment #787223 - Flags: review?(mbrubeck)
Attachment #787223 - Flags: review?(mbrubeck) → review+
On fx-team:  https://hg.mozilla.org/integration/fx-team/rev/8dac6e09d3d6
Whiteboard: [fixed-in-fx-team]
https://hg.mozilla.org/mozilla-central/rev/8dac6e09d3d6
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Whiteboard: [fixed-in-fx-team]
Target Milestone: --- → Firefox 26
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: