CSS Color functions

Scott Palmer swpalmer at gmail.com
Sun Jan 15 00:31:00 UTC 2023


I was looking at Modena.css and came across this:

    /* A bright blue for the focus indicator of objects. Typically used as
the
     * first color in -fx-background-color for the "focused" pseudo-class.
Also
     * typically used with insets of -1.4 to provide a glowing effect.
     */
    -fx-focus-color: #039ED3;
    -fx-faint-focus-color: #039ED322;

I noticed two things pertaining to -fx-faint-focus-color.  Although I've
used this form to specify colors myself, the JavaFX CSS Reference Guide at
https://openjfx.io/javadoc/19/javafx.graphics/javafx/scene/doc-files/cssref.html#typecolor
does
not mention being able to use an 8-digit form of #rrggbbaa when using hex
digits. Only the 3- and 6-digit forms of hexadecimal RGB are mentioned. RGB
+ Alpha colors are only documented in the form of rgba(#,#,#,#) and
rgba(#%,#%,#%,#).

More importantly, this is a copy of -fx-focus-color with an added alpha
channel, but it's created by repeating the literal color value and
appending the alpha component, rather than somehow deriving it from
-fx-focus-color.  Similar repetition is needed for the semi-transparent
chart colors.

Would it make sense to add support for something similar to derive( <color>
, <number>% ) to specify a color based on an existing color with a new
value for the alpha channel (or any other) value? Maybe a color-transform
method that would do for an RGBA color vector what other transforms do for
spatial coordinates?*

Regards,

Scott

* Note: It seems future CSS standards are looking for ways to do similar
things.  A color-mod function was proposed in
https://www.w3.org/TR/2016/WD-css-color-4-20160705/#funcdef-color-mod but
removed in the next revision
https://www.w3.org/TR/2022/CRD-css-color-4-20221101/#changes-from-20160705.
I'm not following CSS development closely, but some googling suggests the
next proposal is based on a new keyword 'from' to create derived colors.
E.g rgb(from skyblue, 255 g b) to get a color based on skyblue with a red
component of 255.  This is mentioned here
https://github.com/w3c/csswg-drafts/issues/3187#issuecomment-499126198  I'm
skeptical that it is worth waiting for the dust to settle on the CSS
standard, but supporting whatever they come up with is a possibility.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/openjfx-dev/attachments/20230114/8449a802/attachment-0001.htm>


More information about the openjfx-dev mailing list