From e819b543f65c17964c36a2371f152b3c5f55d28a Mon Sep 17 00:00:00 2001 From: Context Git Mirror Bot Date: Thu, 31 Mar 2016 10:13:17 +0200 Subject: 2016-03-31 09:10:00 --- metapost/context/base/mpiv/mp-tool.mpiv | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'metapost') diff --git a/metapost/context/base/mpiv/mp-tool.mpiv b/metapost/context/base/mpiv/mp-tool.mpiv index 306b40f0a..05f9d9edc 100644 --- a/metapost/context/base/mpiv/mp-tool.mpiv +++ b/metapost/context/base/mpiv/mp-tool.mpiv @@ -1702,6 +1702,22 @@ enddef ; let greyed = grayed ; +vardef hsvtorgb(expr h,s,v) = + save H, S, V, x ; + H = h mod 360 ; + S = if s < 0 : 0 elseif s > 1 : 1 else: s fi ; + V = if v < 0 : 0 elseif v > 1 : 1 else: v fi ; + x = 1 - abs(H mod 120 - 60)/60 ; + V * ( (1-S) * (1,1,1) + S * + if H < 60 : (1,x,0) + elseif H < 120 : (x,1,0) + elseif H < 180 : (0,1,x) + elseif H < 240 : (0,x,1) + elseif H < 300 : (x,0,1) + else : (1,0,x) + fi ) +enddef ; + % yes or no: "text" infont "cmr12" at 24pt ; % let normalinfont = infont ; -- cgit v1.2.3