Merge lp:~tuxator/midori/colorfull-algo into lp:midori

Proposed by Paweł Forysiuk
Status: Merged
Approved by: Cris Dywan
Approved revision: 6187
Merged at revision: 6199
Proposed branch: lp:~tuxator/midori/colorfull-algo
Merge into: lp:midori
Diff against target: 43 lines (+13/-8)
1 file modified
extensions/colorful-tabs.c (+13/-8)
To merge this branch: bzr merge lp:~tuxator/midori/colorfull-algo
Reviewer Review Type Date Requested Status
Cris Dywan Approve
Review via email: mp+168134@code.launchpad.net

Commit message

Check brightness of backgroung color when deciding foreground color of given tab

To post a comment you must log in.
Revision history for this message
Cris Dywan (kalikiana) wrote :

I like it, it's an existing rather than unknown alogrithm and from testing the sites in the test case and a cuple of websites I tend to visit more often I think it's slightly more right than it used to be judging what's bright and what isn't.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'extensions/colorful-tabs.c'
--- extensions/colorful-tabs.c 2013-05-27 10:51:07 +0000
+++ extensions/colorful-tabs.c 2013-06-07 17:50:33 +0000
@@ -15,14 +15,19 @@
15static GdkColor15static GdkColor
16get_foreground_color_for_GdkColor (GdkColor color)16get_foreground_color_for_GdkColor (GdkColor color)
17{17{
18 /* rgb (160, 160, 160) is gray */
19 guint gray = 160 * 255;
20 GdkColor fgcolor;18 GdkColor fgcolor;
19 gfloat brightness, r, g, b;
20
21 r = color.red / 255;
22 g = color.green / 255;
23 b = color.blue / 255;
24
25 /* For math used see algorithms for converting from rgb to yuv */
26 brightness = 0.299 * r + 0.587 * g + 0.114 * b;
2127
22 /* Ensure high contrast by enforcing black/ white text colour. */28 /* Ensure high contrast by enforcing black/ white text colour. */
23 if ((color.red < gray)29 /* Brigthness (range 0-255) equals value of y from YUV color space. */
24 && (color.green < gray)30 if (brightness < 128)
25 && (color.blue < gray))
26 gdk_color_parse ("white", &fgcolor);31 gdk_color_parse ("white", &fgcolor);
27 else32 else
28 gdk_color_parse ("black", &fgcolor);33 gdk_color_parse ("black", &fgcolor);
@@ -222,11 +227,11 @@
222227
223 static const ColorItem items[] = {228 static const ColorItem items[] = {
224 { "www.last.fm", "#ffffffffffff", "#12ed7da312ed" },229 { "www.last.fm", "#ffffffffffff", "#12ed7da312ed" },
225 { "git.xfce.org", "#000000000000", "#1c424c72e207" },230 { "git.xfce.org", "#ffffffffffff", "#1c424c72e207" },
226 { "elementaryos.org", "#000000000000", "#50dbac36b43e" },231 { "elementaryos.org", "#000000000000", "#50dbac36b43e" },
227 { "news.ycombinator.com", "#000000000000", "#a5cba6cc5278" },232 { "news.ycombinator.com", "#000000000000", "#a5cba6cc5278" },
228 { "cgit.freedesktop.org", "#ffffffffffff", "#95bb8db37ca2" },233 { "cgit.freedesktop.org", "#000000000000", "#95bb8db37ca2" },
229 { "get.cm", "#000000000000", "#1c424c72e207" },234 { "get.cm", "#ffffffffffff", "#1c424c72e207" },
230 };235 };
231236
232 guint i;237 guint i;

Subscribers

People subscribed via source and target branches

to all changes: