Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
David MacDonald
purr-data
Commits
6c315f53
Commit
6c315f53
authored
May 06, 2016
by
Jonathan Wilkes
Browse files
fix lab color typo, use sane variable names, fix default for CT_NULL
parent
06b83e1a
Changes
1
Hide whitespace changes
Inline
Side-by-side
pd/src/g_template.c
View file @
6c315f53
...
...
@@ -1538,17 +1538,19 @@ static t_float hsl_v(t_float m1, t_float m2, t_float h)
return m1;
}
static int hsl_to_int(t_float h, t_float s, t_float l)
static int hsl_to_int(t_float h, t_float s, t_float l
ightness
)
{
t_float m1, m2;
h = ((int)h) % 360;
h = h < 0 ? h + 360 : h;
s = s < 0 ? 0 : s > 1 ? 1 : s;
l
= l
< 0 ? 0 : l > 1 ? 1 : l;
l
ightness = lightness
< 0 ? 0 : l
ightness
> 1 ? 1 : l
ightness
;
m2 = l <= 0.5 ? l * (1 + s) : l + s - l * s;
m1 = 2 * l - m2;
m2 = lightness <= 0.5 ?
lightness * (1 + s) :
lightness + s - lightness * s;
m1 = 2 * lightness - m2;
return (rgb_to_int(
(int)(hsl_v(m1, m2, h + 120) * 255 + 0.5),
...
...
@@ -1558,23 +1560,23 @@ static int hsl_to_int(t_float h, t_float s, t_float l)
t_float lab_xyz(t_float x)
{
return (x > 0.206893034 ? x * x * x : (x - 4 / 29) / 7.787037);
return (x > 0.206893034 ? x * x * x : (x - 4
.
/ 29
.
) / 7.787037);
}
int xyz_rgb(t_float r)
{
return ((int)(0.5 + (255 * (r <= 0.00304 ?
12.92 * r :
1.055 * pow(r, 1 / 2.4) - 0.055))));
1.055 * pow(r, 1
.
/ 2.4) - 0.055))));
}
#define LAB_X 0.950470
#define LAB_Y 1
#define LAB_Y 1
.
#define LAB_Z 1.088830
static int lab_to_int(t_float l, t_float a, t_float b)
static int lab_to_int(t_float l
ightness
, t_float a, t_float b)
{
t_float y, x, z;
y = (
1
+ 16) / 116.;
y = (
lightness
+ 16) / 116.;
x = y + a / 500.;
z = y - b / 200.;
...
...
@@ -1592,10 +1594,10 @@ static char *svg_get_color(t_fielddesc *fd, t_colortype ct,
t_template *template, t_word *data)
{
static char str[10];
if (ct == CT_SYM)
{
if (ct == CT_NULL)
sprintf(str, "none");
else if (ct == CT_SYM)
sprintf(str, "%s", fielddesc_getsymbol(fd, template, data, 1)->s_name);
}
else
{
t_float c1, c2, c3;
...
...
@@ -1695,15 +1697,12 @@ void svg_sendupdate(t_svg *x, t_canvas *c, t_symbol *s,
*predraw_bbox = 1;
else if (s == gensym("fill"))
{
// else
// fill = &s_;
gui_vmess("gui_draw_configure", "xsss",
glist_getcanvas(c), tag, s->s_name,
svg_get_color(x->x_fill, x->x_filltype, template, data));
}
else if (s == gensym("stroke"))
{
// else stroke = &s_;
gui_vmess("gui_draw_configure", "xsss",
glist_getcanvas(c), tag, s->s_name,
svg_get_color(x->x_stroke, x->x_stroketype, template, data));
...
...
@@ -2297,7 +2296,6 @@ static int svg_set_color(t_svg *x, t_colortype *type, t_fielddesc *cfield,
char *col = svg_get_color(fd, *type, 0, 0);
fielddesc_setsymbol_const(cfield, gensym(col));
*type = CT_SYM;
// *type = CT_RGB;
}
}
else
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment