diff options
Diffstat (limited to 'metapost')
-rw-r--r-- | metapost/context/base/mp-spec.mp | 42 | ||||
-rw-r--r-- | metapost/context/base/mp-tool.mp | 16 |
2 files changed, 36 insertions, 22 deletions
diff --git a/metapost/context/base/mp-spec.mp b/metapost/context/base/mp-spec.mp index d4c2b8cfc..351f9fe1c 100644 --- a/metapost/context/base/mp-spec.mp +++ b/metapost/context/base/mp-spec.mp @@ -330,33 +330,26 @@ def set_linear_vector (suffix a,b)(expr p,n) = fi ; enddef ; +def set_circular_vector (suffix ab, r)(expr p,n) = + if (n=1) : ab := llcorner p ; + elseif (n=2) : ab := lrcorner p ; + elseif (n=3) : ab := urcorner p ; + elseif (n=4) : ab := ulcorner p ; + else : ab := center p ; r := .5r ; + fi ; +enddef ; + def linear_shade (expr p, n, ca, cb) = begingroup ; save a, b, sh ; pair a, b ; set_linear_vector(a,b)(p,n) ; fill p withshade define_linear_shade (a,b,ca,cb) ; if trace_shades : - drawarrow a -- b withpen pencircle scaled 1pt ; + drawarrow a -- b withpen pencircle scaled 1pt withcolor .5white ; fi ; endgroup ; enddef ; -vardef predefined_linear_shade (expr p, n, ca, cb) = - save a, b, sh ; pair a, b ; - set_linear_vector(a,b)(p,n) ; - set_shade_vector(a,b)(p,n) ; - define_linear_shade (a,b,ca,cb) -enddef ; - -def set_circular_vector (suffix ab, r)(expr p,n) = - if (n=1) : ab := llcorner p ; - elseif (n=2) : ab := lrcorner p ; - elseif (n=3) : ab := urcorner p ; - elseif (n=4) : ab := ulcorner p ; - else : ab := center p ; r := .5r ; - fi ; -enddef ; - def circular_shade (expr p, n, ca, cb) = begingroup ; save ab, r ; pair ab ; numeric r ; @@ -365,11 +358,18 @@ def circular_shade (expr p, n, ca, cb) = set_circular_vector(ab,r)(p,n) ; fill p withshade define_circular_shade(ab,ab,0,r,ca,cb) ; if trace_shades : - drawarrow ab -- ab shifted (0,r) withpen pencircle scaled 1pt ; + drawarrow ab -- ab shifted (0,r) withpen pencircle scaled 1pt withcolor .5white ; fi ; endgroup ; enddef ; +vardef predefined_linear_shade (expr p, n, ca, cb) = + save a, b, sh ; pair a, b ; + set_linear_vector(a,b)(p,n) ; + set_shade_vector(a,b)(p,n) ; + define_linear_shade (a,b,ca,cb) +enddef ; + vardef predefined_circular_shade (expr p, n, ca, cb) = save ab, r ; pair ab ; numeric r ; r := (xpart lrcorner p - xpart llcorner p) ++ @@ -512,9 +512,9 @@ enddef ; % newcolor truecyan, truemagenta, trueyellow ; % -% truecyan = cmyk (1,0,0,0) ; -% truemagenta = cmyk (0,1,0,0) ; -% trueyellow = cmyk (0,0,1,0) ; +% truecyan = (1,0,0,0) ; +% truemagenta = (0,1,0,0) ; +% trueyellow = (0,0,1,0) ; %D Spot colors diff --git a/metapost/context/base/mp-tool.mp b/metapost/context/base/mp-tool.mp index 567ff16fd..b8e2dd668 100644 --- a/metapost/context/base/mp-tool.mp +++ b/metapost/context/base/mp-tool.mp @@ -116,7 +116,21 @@ extra_endfig := extra_endfig %D Also handy (when we flush colors): vardef dddecimal primary c = - decimal redpart c & " " & decimal greenpart c & " " & decimal bluepart c + decimal redpart c & " " & decimal greenpart c & " " & decimal bluepart c +enddef ; + +vardef ddddecimal primary c = + decimal cyanpart c & " " & decimal magentapart c & " " & decimal yellowpart c & " " & decimal blackpart c +enddef ; + +vardef colordecimals primary c = + if cmykcolor c : + decimal cyanpart c & ":" & decimal magentapart c & ":" & decimal yellowpart c & ":" & decimal blackpart c + elseif rgbcolor c : + decimal redpart c & ":" & decimal greenpart c & ":" & decimal bluepart c + else : + decimal c + fi enddef ; %D We have standardized data file names: |