From: Jun T <takimoto-j@kba.biglobe.ne.jp>
To: zsh-workers@zsh.org
Subject: Re: Terminal theme tool – a workaround for lack of 24-bit color in Zsh?
Date: Fri, 16 Nov 2018 16:54:51 +0900 [thread overview]
Message-ID: <0B27AD49-061D-4A49-BE6C-85F601AAA067@kba.biglobe.ne.jp> (raw)
In-Reply-To: <1542285877.4637.3.camel@samsung.com>
Is it OK to replace all floats by doubles?
What we get is just to silence the (non-standard) warnings.
diff --git a/Src/Modules/nearcolor.c b/Src/Modules/nearcolor.c
index 0b9877bf4..b49ee9afb 100644
--- a/Src/Modules/nearcolor.c
+++ b/Src/Modules/nearcolor.c
@@ -33,37 +33,37 @@
#include <math.h>
struct cielab {
- float L, a, b;
+ double L, a, b;
};
typedef struct cielab *Cielab;
-static float
+static double
deltae(Cielab lab1, Cielab lab2)
{
/* taking square root unnecessary as we're just comparing values */
- return powf(lab1->L - lab2->L, 2) +
- powf(lab1->a - lab2->a, 2) +
- powf(lab1->b - lab2->b, 2);
+ return pow(lab1->L - lab2->L, 2) +
+ pow(lab1->a - lab2->a, 2) +
+ pow(lab1->b - lab2->b, 2);
}
static void
RGBtoLAB(int red, int green, int blue, Cielab lab)
{
- float R = (float)red / 255.0;
- float G = (float)green / 255.0;
- float B = (float)blue / 255.0;
- R = 100.0 * (R > 0.04045 ? powf((R + 0.055) / 1.055, 2.4) : R / 12.92);
- G = 100.0 * (G > 0.04045 ? powf((G + 0.055) / 1.055, 2.4) : G / 12.92);
- B = 100.0 * (B > 0.04045 ? powf((B + 0.055) / 1.055, 2.4) : B / 12.92);
+ double R = red / 255.0;
+ double G = green / 255.0;
+ double B = blue / 255.0;
+ R = 100.0 * (R > 0.04045 ? pow((R + 0.055) / 1.055, 2.4) : R / 12.92);
+ G = 100.0 * (G > 0.04045 ? pow((G + 0.055) / 1.055, 2.4) : G / 12.92);
+ B = 100.0 * (B > 0.04045 ? pow((B + 0.055) / 1.055, 2.4) : B / 12.92);
/* Observer. = 2 degrees, Illuminant = D65 */
- float X = (R * 0.4124 + G * 0.3576 + B * 0.1805) / 95.047;
- float Y = (R * 0.2126 + G * 0.7152 + B * 0.0722) / 100.0;
- float Z = (R * 0.0193 + G * 0.1192 + B * 0.9505) / 108.883;
+ double X = (R * 0.4124 + G * 0.3576 + B * 0.1805) / 95.047;
+ double Y = (R * 0.2126 + G * 0.7152 + B * 0.0722) / 100.0;
+ double Z = (R * 0.0193 + G * 0.1192 + B * 0.9505) / 108.883;
- X = (X > 0.008856) ? powf(X, 1.0/3.0) : (7.787 * X) + (16.0 / 116.0);
- Y = (Y > 0.008856) ? powf(Y, 1.0/3.0) : (7.787 * Y) + (16.0 / 116.0);
- Z = (Z > 0.008856) ? powf(Z, 1.0/3.0) : (7.787 * Z) + (16.0 / 116.0);
+ X = (X > 0.008856) ? pow(X, 1.0/3.0) : (7.787 * X) + (16.0 / 116.0);
+ Y = (Y > 0.008856) ? pow(Y, 1.0/3.0) : (7.787 * Y) + (16.0 / 116.0);
+ Z = (Z > 0.008856) ? pow(Z, 1.0/3.0) : (7.787 * Z) + (16.0 / 116.0);
lab->L = (116.0 * Y) - 16.0;
lab->a = 500.0 * (X - Y);
@@ -75,7 +75,7 @@ mapRGBto88(int red, int green, int blue)
{
int component[] = { 0, 0x8b, 0xcd, 0xff, 0x2e, 0x5c, 0x8b, 0xa2, 0xb9, 0xd0, 0xe7 };
struct cielab orig, next;
- float nextl, bestl = -1;
+ double nextl, bestl = -1;
int r, g, b;
int comp_r = 0, comp_g = 0, comp_b = 0;
@@ -116,7 +116,7 @@ mapRGBto256(int red, int green, int blue)
0xa8, 0xb2, 0xbc, 0xc6, 0xd0, 0xda, 0xe4, 0xee
};
struct cielab orig, next;
- float nextl, bestl = -1;
+ double nextl, bestl = -1;
int r, g, b;
int comp_r = 0, comp_g = 0, comp_b = 0;
next prev parent reply other threads:[~2018-11-16 7:55 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CAKc7PVCEmTTMRR0P3kx9ktpLDBYqJ+MRsE77UMLFjonEZAixfA@mail.gmail.com>
2018-10-30 23:41 ` Oliver Kiddle
2018-11-01 18:42 ` dana
2018-11-04 1:42 ` PATCH: true colour support Oliver Kiddle
2018-11-04 22:57 ` Oliver Kiddle
2018-11-05 14:36 ` Sebastian Gniazdowski
[not found] ` <46482-1541429525.040210@53iC.Cv7F.M2xE>
2018-11-05 15:48 ` Sebastian Gniazdowski
2018-11-05 16:22 ` Sebastian Gniazdowski
2018-11-06 12:12 ` Sebastian Gniazdowski
2018-11-06 13:37 ` Oliver Kiddle
2018-11-06 21:46 ` Sebastian Gniazdowski
2018-11-06 12:22 ` Should there be a Zsh release for true-color support to adopt earlier? Sebastian Gniazdowski
2018-11-06 22:35 ` Daniel Shahaf
2018-11-06 23:46 ` Bart Schaefer
2018-11-05 14:03 ` Terminal theme tool – a workaround for lack of 24-bit color in Zsh? Sebastian Gniazdowski
2018-11-15 11:50 ` Jun T
2018-11-15 12:44 ` Peter Stephenson
2018-11-16 7:54 ` Jun T [this message]
2018-11-19 8:29 ` Oliver Kiddle
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=0B27AD49-061D-4A49-BE6C-85F601AAA067@kba.biglobe.ne.jp \
--to=takimoto-j@kba.biglobe.ne.jp \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).