summaryrefslogtreecommitdiff
path: root/metapost
diff options
context:
space:
mode:
Diffstat (limited to 'metapost')
-rw-r--r--metapost/context/base/mp-mlib.mp52
1 files changed, 50 insertions, 2 deletions
diff --git a/metapost/context/base/mp-mlib.mp b/metapost/context/base/mp-mlib.mp
index 9929cfde5..6c7115cb7 100644
--- a/metapost/context/base/mp-mlib.mp
+++ b/metapost/context/base/mp-mlib.mp
@@ -359,8 +359,7 @@ vardef define_linear_shade (expr a, b, ca, cb) =
enddef ;
primarydef p withshade sc =
- p
- withprescript _defined_cs_pre_[sc]
+ p withprescript _defined_cs_pre_[sc]
enddef ;
% vardef predefined_linear_shade (expr p, n, ca, cb) =
@@ -376,6 +375,55 @@ enddef ;
% define_circular_shade(ab,ab,0,r,ca,cb)
% enddef ;
+% NEW EXPERIMENTAL CODE
+
+def withlinearshading (expr a, b) =
+ withprescript "sh_type=linear"
+ withprescript "sh_domain=0 1"
+ withprescript "sh_factor=" & decimal shadefactor
+ withprescript "sh_center_a=" & ddecimal (a shifted shadeoffset)
+ withprescript "sh_center_b=" & ddecimal (b shifted shadeoffset)
+enddef ;
+
+def withcircularshading (expr a, b, ra, rb) =
+ withprescript "sh_type=circular"
+ withprescript "sh_domain=0 1"
+ withprescript "sh_factor=" & decimal shadefactor
+ withprescript "sh_center_a=" & ddecimal (a shifted shadeoffset)
+ withprescript "sh_center_b=" & ddecimal (b shifted shadeoffset)
+ withprescript "sh_radius_a=" & decimal ra
+ withprescript "sh_radius_b=" & decimal rb
+enddef ;
+
+def withfromshadecolor expr t =
+ withprescript "sh_color=into"
+ withprescript "sh_color_a=" & colordecimals t
+enddef ;
+
+def withtoshadecolor expr t =
+ withprescript "sh_color=into"
+ withprescript "sh_color_b=" & colordecimals t
+enddef ;
+
+def withshading (expr how)(text rest) =
+ if how = "linear" :
+ withlinearshading(rest)
+ elseif how = "circular" :
+ withcircularshading(rest)
+ else :
+ % nothing
+ fi
+enddef ;
+
+primarydef a shadedinto b =
+ 1
+ withprescript "sh_color=into"
+ withprescript "sh_color_a=" & colordecimals a
+ withprescript "sh_color_b=" & colordecimals b
+enddef ;
+
+% END OF NEW
+
% Graphic text (we will move code here)
def graphictext primary t =