wrangle: hsv sliders to modify a previous color?

   133   3   1
User Avatar
Member
487 posts
Joined: April 2017
Offline
Hi!

I understand I can use the hsvtorgb function to create a color from 3 separate colors. I would like to know how I can use my hsv values to modify an existing color.

-Olivier
User Avatar
Member
487 posts
Joined: April 2017
Offline
…Ok, so I found something that works but could be better.

float H = chf("H") - 0.5;
float S = chf("S") - 0.5;
float V = chf("V") - 0.5;

vector tohsv = rgbtohsv(@Cd);
v@test = tohsv;

tohsv += set(H, S, V);
tohsv = clamp(tohsv, 0.000001, 0.9999);
tohsv = frac(tohsv);

@Cd = hsvtorgb(tohsv);

-Olivier
User Avatar
Member
422 posts
Joined: Sept. 2013
Offline
Hi Olivier,

you could change existing colors by transforming them to HSV like this:

float hue = chf('hue');
float sat = chf('saturation');
float val = chf('value');

vector color_hsv = rgbtohsv(v@Cd);

color_hsv[0] += hue;
color_hsv[1] *= sat;
color_hsv[2] *= val;

v@Cd = hsvtorgb(color_hsv);

Attachments:
hsv_colors.hiplc (127.2 KB)

User Avatar
Member
487 posts
Joined: April 2017
Offline
Ah! much better!

Thanks.

-Olivier
  • Quick Links