Re: [fltk/fltk] Not enough contrast on automatic colors (Issue #370)
Albrecht Schlosser
Jul 20, 2022
@Myndex In FLTK we use fl_contrast(fg, bg) as documented here to return a color with "sufficient" contrast: either the foreground color or black or white.
The current implementation is fontsize agnostic. The future version has two more parameters:
You can view the new documentation at the same location as soon as I pushed a commit but this may take a few more hours.
The context parameter is intended to differentiate text from other objects (icons for instance) but this is not yet implemented in any way.
The fontsize (fs) parameter will be used to define what contrast value is "sufficient". My current experimental (not public) evaluation implementation uses an inverted and interpolated version of your font lookup table to determine "sufficient" contrast per font size (at font weight 600):
These values are experimental but I believe we can't use font weight internally in any way because we don't "know" what exact font (weight) the user is applying to the calculation.
As opposed to your suggestion to use a larger font if the contrast is loo low, we require a higher "sufficient" contrast if the font is smaller. This sufficient contrast is only used in the first part of the calculation. If the contrast is sufficient the foreground color is returned, otherwise black or white depending on the background color.
I hope this was helpful. Thanks for reading.
Albrecht
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you are subscribed to this thread.Message ID: <fltk/fltk/issues/370/1190195694@github.com>
Comments are owned by the poster. All other content is copyright 1998-2025 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.