FLTK logo

Re: [fltk/fltk] Not enough contrast on automatic colors (Issue #370)

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.issues  ]
 
Previous Message ]New Message | Reply ]Next Message ]

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:

Fl_Color fl_contrast(Fl_Color fg, Fl_Color bg, Fl_Fontsize fs = 0, int context = 0);

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):

  int Lc[20] = {
  // 10   11   12   13   14   15   16   17   18   19  // font size
    125, 115, 110, 105,  95,  75,  70,  65,  60,  58, // min. Lc
  // 20   21   22   23   24   25   26   27   28   29  // font size
     56,  55,  54,  52,  50,  48,  47,  46,  45,  43  // min. Lc
  };

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>

Direct Link to Message ]
 
     
Previous Message ]New Message | Reply ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.