From kde-usability Sun Aug 10 15:21:50 2003 From: Tim Jansen Date: Sun, 10 Aug 2003 15:21:50 +0000 To: kde-usability Subject: Re: [PATCH] Striking out finished todos (wish #62430) X-MARC-Message: https://marc.info/?l=kde-usability&m=106052885608274 On Sunday 10 August 2003 16:57, Reinhold Kainhofer wrote: > Okay, I played around a little bit with different choices of marking > finished todos visually. Unfortunately some of your links are broken: http://reinhold.kainhofer.com/Linux/pictures/KOrganizer_FinishedTodosStrikeOut6.png http://reinhold.kainhofer.com/Linux/pictures/KOrganizer_FinishedTodosStrikeOut2.png http://reinhold.kainhofer.com/Linux/pictures/KOrganizer_FinishedTodosStrikeOut5.png http://reinhold.kainhofer.com/Linux/pictures/KOrganizer_FinishedTodosStrikeOut4.png > suggested by danimo). One problem, however, is that in that case we need > to find a good way to determine a color, which still shows good contrast > to all background colors. Use this function to determine the luminance (0-255) of the background: float getLuminance(const QColor &c) { return (c.red() * 0.299) + (c.green() * 0.587) + (c.blue() * 0.114); } If it is >128 it is a bright background, and black the right color. Otherwise use white: QColor getTextColor(const QColor &bgColor) { float luminance = getLuminance(bgColor); return (luminance > 128.0) ? QColor( 0, 0 ,0 ) : QColor( 255, 255 ,255 ); } In order to get a lighter color, mix the text color with the backgroung color: QColor mixColors(double p1, QColor c1, QColor c2) { return QColor(int(c1.red() * p1 + c2.red() * (1.0-p1)), int(c1.green() * p1 + c2.green() * (1.0-p1)), int(c1.blue() * p1 + c2.blue() * (1.0-p1))); } QColor getLightTextColor(const QColor &bgColor) { const int LightColorFactor = 0.75; // find a good one return mixColor(LightColorFactor, getTextColor(bgColor), bgColor); } Maybe these functions should be put into a central place (kdefx?), I have also used them in KWordWrap and KOAgendaItem. bye... _______________________________________________ kde-usability mailing list kde-usability@mail.kde.org http://mail.kde.org/mailman/listinfo/kde-usability