toga icon indicating copy to clipboard operation
toga copied to clipboard

Add utility methods to darken/lighten colors

Open freakboy3742 opened this issue 1 year ago • 1 comments

What is the problem or limitation you are having?

Tools like SCSS and SASS provide utility methods to darken an lighten colors. These can be useful for defining de-emphasized secondary headings etc. Toga should provide utility methods to

Describe the solution you'd like

It should be possible to call toga.Color(...).lighten(X) or toga.Color(...).darken(X) to generate a new color that is lighter/darker by X% (where X is a float in the range 0-1).

It may also be useful to have analogs of these methods that go in the right "direction" when dark mode is taken into account (i.e. in light mode, lightening is used for de-emphasis; but in dark mode, darkening is used for de-emphasis). See #2841 for a related issue.

Describe alternatives you've considered

This is already possible using HSL colorspace definitions; however, Travertino doesn't provide mechanism for converting from RGBA to HSLA.

Additional context

See #2830 for the original request.

freakboy3742 avatar Sep 14 '24 09:09 freakboy3742

Update: as of #3140, we now have RGBA -> HSLA conversion, so this is halfway there!

HalfWhitt avatar Aug 15 '25 00:08 HalfWhitt