DynamicColor icon indicating copy to clipboard operation
DynamicColor copied to clipboard

Inverting brightness only.

Open davidbjames opened this issue 6 years ago • 0 comments

It would be helpful to invert only the brightness while retaining the hue and saturation of a color. Is this possible? There is currently DynamicColor.invert. Would it be useful to add a DynamicColor.invertBrightness ?

I tried with the following code, and I get inconsistent results (for example, light-medium orange becomes almost black instead of dark orange). Mostly I'm finding the resulting colors are darker then I would expect.

let hue = hueComponent
let saturation = saturationComponent
let brightness = 1 - brightnessComponent
let alpha = alphaComponent
return DynamicColor(hue:hue, saturation:saturation, brightness:brightness, alpha:alpha)

davidbjames avatar Jun 11 '19 11:06 davidbjames