Metapost Sandbox
Debug
save
Save
play_arrow
Run
download
Export
share
Share
Link to share
Embed
person
Login using Github
My work
New...
Log out
Documentation
About
vardef hsl_color(expr h, s, l) = save chroma, hh, x, m; chroma = (1 - abs(2 * l - 1)) * s; hh = h / 60; x = chroma * (1 - abs(hh mod 2 - 1)); m = l - chroma / 2; if hh < 1: (chroma,x,0)+(m,m,m) elseif hh < 2: (x,chroma,0)+(m,m,m) elseif hh < 3: (0,chroma,x)+(m,m,m) elseif hh < 4: (0,x,chroma)+(m,m,m) elseif hh < 5: (x,0,chroma)+(m,m,m) else: (chroma,0,x)+(m,m,m) fi enddef; beginfig(0); numeric s[], l[]; s0 = 0.5; l0 = 0.3; % First row: medium saturation, high lightness s1 = 0.75; l1 = 0.4; % Second row: high saturation, high lightness s2 = 1; l2 = 0.5; % Third row: high saturation, medium lightness path r; for y = 0, 1, 2: for h = 0 step 15 until 360: r := fullcircle scaled 24 shifted (h, -36 * y if y = 2: +8 fi); fill r withcolor hsl_color(h, s[y], l[y]); draw r withcolor white; endfor endfor label.urt("Less saturation", (-20, 14)); label.lrt("Lower lightness", (-20, -78)); drawarrow (-15, -21) -- (-15, 12); drawarrow (-15, -43) -- (-15, -76); endfig; end