Coding style.

This commit is contained in:
Sebastian Ramacher 2012-08-01 16:15:35 +02:00
parent c57463a053
commit 9c28be7c11

View File

@ -89,7 +89,7 @@ render_page(render_thread_t* render_thread, zathura_page_t* page)
return true; return true;
} }
void static void
color2double(GdkColor* col, double* v) color2double(GdkColor* col, double* v)
{ {
v[0] = (double) col->red / 65535.; v[0] = (double) col->red / 65535.;
@ -100,7 +100,7 @@ color2double(GdkColor* col, double* v)
/* Returns the maximum possible saturation for given h and l. /* Returns the maximum possible saturation for given h and l.
Assumes that l is in the interval l1, l2 and corrects the value to Assumes that l is in the interval l1, l2 and corrects the value to
force u=0 on l1 and l2 */ force u=0 on l1 and l2 */
double static double
colorumax(double* h, double l, double l1, double l2) colorumax(double* h, double l, double l1, double l2)
{ {
double u, uu, v, vv, lv; double u, uu, v, vv, lv;
@ -109,22 +109,28 @@ colorumax(double* h, double l, double l1, double l2)
} }
lv = (l - l1)/(l2 - l1); /* Remap l to the whole interval 0,1 */ lv = (l - l1)/(l2 - l1); /* Remap l to the whole interval 0,1 */
u = v = 1000000; u = v = 1000000;
for (int k = 0; k < 3; k++) { for (int k = 0; k < 3; k++) {
if (h[k] > 0) { if (h[k] > 0) {
uu = fabs((1-l)/h[k]); uu = fabs((1-l)/h[k]);
vv = fabs((1-lv)/h[k]); vv = fabs((1-lv)/h[k]);
if (uu < u) u = uu; if (uu < u) {
if (vv < v) v = vv; u = uu;
}
if (vv < v) {
v = vv;
}
} else if (h[k] < 0) { } else if (h[k] < 0) {
uu = fabs(l/h[k]); uu = fabs(l/h[k]);
vv = fabs(lv/h[k]); vv = fabs(lv/h[k]);
if (uu < u) u = uu; if (uu < u) {
if (vv < v) v = vv; u = uu;
}
if (vv < v) {
v = vv;
}
} }
} }
@ -194,9 +200,7 @@ render(zathura_t* zathura, zathura_page_t* page)
- a hue vector, which indicates a radian direction from the grey axis, inside the equal lightness plane. - a hue vector, which indicates a radian direction from the grey axis, inside the equal lightness plane.
- a saturation scalar between 0,1. It is 0 when grey, 1 when the color is in the boundary of the rgb cube. - a saturation scalar between 0,1. It is 0 when grey, 1 when the color is in the boundary of the rgb cube.
*/ */
if (zathura->global.recolor == true) { if (zathura->global.recolor == true) {
/* RGB weights for computing lightness. Must sum to one */ /* RGB weights for computing lightness. Must sum to one */
double a[] = {0.30, 0.59, 0.11}; double a[] = {0.30, 0.59, 0.11};
@ -228,8 +232,11 @@ render(zathura_t* zathura, zathura_page_t* page)
/* u is the maximum possible saturation for given h and l. s is a rescaled saturation between 0 and 1 */ /* u is the maximum possible saturation for given h and l. s is a rescaled saturation between 0 and 1 */
u = colorumax(h, l, 0, 1); u = colorumax(h, l, 0, 1);
if (u == 0) s = 0; if (u == 0) {
else s = 1/u; s = 0;
} else {
s = 1/u;
}
/* Interpolates lightness between light and dark colors. white goes to light, and black goes to dark. */ /* Interpolates lightness between light and dark colors. white goes to light, and black goes to dark. */
t = l; t = l;