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
% based on https://tug.ctan.org/info/drawing-with-metapost/Drawing-with-Metapost.pdf vardef hsv_color(expr h, s, v) = save chroma, hh, x, m; chroma = v * s; hh = h / 60; x = chroma * (1 - abs(hh mod 2 - 1)); m = v - chroma; 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[], v[]; s0 = 1/2; v0 = 7/8; s1 = 7/8; v1 = 7/8; s2 = 7/8; v2 = 1/2; path r; for y=0, 1, 2: for h=0 step 15 until 360: r := fullcircle scaled 24 shifted (h, -36y if y=2: +8 fi); fill r withcolor hsv_color(h, s[y], v[y]); draw r withcolor white; endfor endfor label.urt("Less saturation", (-20,14)); label.lrt("Lower value", (-20,-78)); drawarrow (-15, -21) -- (-15,12); drawarrow (-15, -43) -- (-15,-76); endfig; end