1#include "colorspaces.hpp"
10 double min, max, delta;
12 min = in.r < in.g ? in.r : in.g;
13 min = min < in.b ? min : in.b;
15 max = in.r > in.g ? in.r : in.g;
16 max = max > in.b ? max : in.b;
27 out.s = (delta / max);
36 out.h = ( in.g - in.b ) / delta;
39 out.h = 2.0 + ( in.b - in.r ) / delta;
41 out.h = 4.0 + ( in.r - in.g ) / delta;
54 double hh, p, q, t, ff;
65 if(hh >= 360.0) hh = 0.0;
69 p = in.v * (1.0 - in.s);
70 q = in.v * (1.0 - (in.s * ff));
71 t = in.v * (1.0 - (in.s * (1.0 - ff)));
110rgb fromRGB(
int r,
int g,
int b)
112 return { r/255.0, g/255.0, b/255.0 };
116 return (
double)std::rand() / ((double)RAND_MAX + 1);
121 return (
rgb){ randd(), randd(), randd() };