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
1=== modified file 'extensions/colorful-tabs.c'
2--- extensions/colorful-tabs.c 2013-05-27 10:51:07 +0000
3+++ extensions/colorful-tabs.c 2013-06-07 17:50:33 +0000
4@@ -15,14 +15,19 @@
5 static GdkColor
6 get_foreground_color_for_GdkColor (GdkColor color)
7 {
8- /* rgb (160, 160, 160) is gray */
9- guint gray = 160 * 255;
10 GdkColor fgcolor;
11+ gfloat brightness, r, g, b;
12+
13+ r = color.red / 255;
14+ g = color.green / 255;
15+ b = color.blue / 255;
16+
17+ /* For math used see algorithms for converting from rgb to yuv */
18+ brightness = 0.299 * r + 0.587 * g + 0.114 * b;
19
20 /* Ensure high contrast by enforcing black/ white text colour. */
21- if ((color.red < gray)
22- && (color.green < gray)
23- && (color.blue < gray))
24+ /* Brigthness (range 0-255) equals value of y from YUV color space. */
25+ if (brightness < 128)
26 gdk_color_parse ("white", &fgcolor);
27 else
28 gdk_color_parse ("black", &fgcolor);
29@@ -222,11 +227,11 @@
30
31 static const ColorItem items[] = {
32 { "www.last.fm", "#ffffffffffff", "#12ed7da312ed" },
33- { "git.xfce.org", "#000000000000", "#1c424c72e207" },
34+ { "git.xfce.org", "#ffffffffffff", "#1c424c72e207" },
35 { "elementaryos.org", "#000000000000", "#50dbac36b43e" },
36 { "news.ycombinator.com", "#000000000000", "#a5cba6cc5278" },
37- { "cgit.freedesktop.org", "#ffffffffffff", "#95bb8db37ca2" },
38- { "get.cm", "#000000000000", "#1c424c72e207" },
39+ { "cgit.freedesktop.org", "#000000000000", "#95bb8db37ca2" },
40+ { "get.cm", "#ffffffffffff", "#1c424c72e207" },
41 };
42
43 guint i;

Subscribers

People subscribed via source and target branches

to all changes: