summaryrefslogtreecommitdiff
path: root/metapost/context/base
diff options
context:
space:
mode:
authorContext Git Mirror Bot <phg42.2a@gmail.com>2016-08-15 23:17:11 +0200
committerContext Git Mirror Bot <phg42.2a@gmail.com>2016-08-15 23:17:11 +0200
commit30b3a925bfc1857a31e23d9b17b8da0be572d02a (patch)
tree994685218d0ab6c1c65df36dcc5a5a08a231171e /metapost/context/base
parent01440ae8999ee20351f0538792e415ade8cd3d5c (diff)
downloadcontext-30b3a925bfc1857a31e23d9b17b8da0be572d02a.tar.gz
2016-08-15 22:45:00
Diffstat (limited to 'metapost/context/base')
-rw-r--r--metapost/context/base/mpiv/mp-luas.mpiv2
-rw-r--r--metapost/context/base/mpiv/mp-mlib.mpiv56
-rw-r--r--metapost/context/base/mpiv/mp-tool.mpiv22
3 files changed, 80 insertions, 0 deletions
diff --git a/metapost/context/base/mpiv/mp-luas.mpiv b/metapost/context/base/mpiv/mp-luas.mpiv
index c30798247..c7c97228e 100644
--- a/metapost/context/base/mpiv/mp-luas.mpiv
+++ b/metapost/context/base/mpiv/mp-luas.mpiv
@@ -97,3 +97,5 @@ enddef ;
vardef MP@#(text t) =
mlib_luas_lualist("MP." & str @#,t)
enddef ;
+
+def message = lua.mp.report enddef ;
diff --git a/metapost/context/base/mpiv/mp-mlib.mpiv b/metapost/context/base/mpiv/mp-mlib.mpiv
index a4541ae2d..ea148d0c1 100644
--- a/metapost/context/base/mpiv/mp-mlib.mpiv
+++ b/metapost/context/base/mpiv/mp-mlib.mpiv
@@ -585,6 +585,7 @@ primarydef p withshademethod m =
hide(mfun_with_shade_method_analyze(p))
p
withprescript "sh_domain=0 1"
+ withprescript "sh_transform=yes"
withprescript "sh_color=into"
withprescript "sh_color_a=" & colordecimals white
withprescript "sh_color_b=" & colordecimals black
@@ -611,6 +612,16 @@ primarydef p withshademethod m =
fi
enddef ;
+def withshaderadius expr a =
+ withprescript "sh_radius_a=" & decimal (xpart a)
+ withprescript "sh_radius_b=" & decimal (ypart a)
+enddef ;
+
+def withshadeorigin expr a =
+ withprescript "sh_center_a=" & ddecimal a
+ withprescript "sh_center_b=" & ddecimal a
+enddef ;
+
def withshadevector expr a =
withprescript "sh_center_a=" & ddecimal (point xpart a of mfun_shade_path)
withprescript "sh_center_b=" & ddecimal (point ypart a of mfun_shade_path)
@@ -621,6 +632,10 @@ def withshadedirection expr a =
withprescript "sh_center_b=" & ddecimal (point ypart a of boundingbox(mfun_shade_path))
enddef ;
+def withshadetransform expr a = % yes | no
+ withprescript "sh_transform=" & a
+enddef ;
+
pair shadedup ; shadedup := (0.5,2.5) ;
pair shadeddown ; shadeddown := (2.5,0.5) ;
pair shadedleft ; shadedleft := (1.5,3.5) ;
@@ -690,10 +705,47 @@ def shaded text s =
s
enddef ;
+% For me.
+
+primarydef p shownshadevector v =
+ image (
+ drawarrow (point xpart v of p) -- (point ypart v of p) ;
+ fill fullcircle scaled 2 shifted point xpart v of p ;
+ setbounds currentpicture to center currentpicture -- cycle ;
+ )
+enddef ;
+
+primarydef p shownshadedirection v =
+ image (
+ drawarrow (point xpart v of boundingbox p) -- (point ypart v of boundingbox p) ;
+ fill fullcircle scaled 2 shifted (point xpart v of boundingbox p) ;
+ setbounds currentpicture to center currentpicture -- cycle ;
+ )
+enddef ;
+
+primarydef p shownshadecenter v =
+ image (
+ fill fullcircle scaled 2
+ shifted center p shifted (
+ xpart v * bbwidth (p)/2,
+ ypart v * bbheight(p)/2
+ ) ;
+ setbounds currentpicture to center currentpicture -- cycle ;
+ )
+enddef ;
+
+primarydef p shownshadeorigin v =
+ image (
+ fill fullcircle scaled 2 shifted v ;
+ setbounds currentpicture to center currentpicture -- cycle ;
+ )
+enddef ;
+
% Old macros:
def withcircularshade (expr a, b, ra, rb, ca, cb) =
withprescript "sh_type=circular"
+ withprescript "sh_transform=yes"
withprescript "sh_domain=0 1"
withprescript "sh_factor=1"
withprescript "sh_color_a=" & colordecimals ca
@@ -706,6 +758,7 @@ enddef ;
def withlinearshade (expr a, b, ca, cb) =
withprescript "sh_type=linear"
+ withprescript "sh_transform=yes"
withprescript "sh_domain=0 1"
withprescript "sh_factor=1"
withprescript "sh_color_a=" & colordecimals ca
@@ -1530,6 +1583,9 @@ vardef formatted(expr f, x) = textext(varfmt(f, x)) enddef ;
% def strfmt = format enddef ; % old
% def varfmt = formatted enddef ; % old
+
+def fmttext = lua.mp.formatted enddef ;
+
% new
def fillup text t = draw t withpostscript "both" enddef ; % we use draw because we need the proper boundingbox
diff --git a/metapost/context/base/mpiv/mp-tool.mpiv b/metapost/context/base/mpiv/mp-tool.mpiv
index 4922d5075..220a7b6a9 100644
--- a/metapost/context/base/mpiv/mp-tool.mpiv
+++ b/metapost/context/base/mpiv/mp-tool.mpiv
@@ -1246,6 +1246,15 @@ vardef arrowheadonpath (expr p, s) =
arrowhead p if s < 1 : cutafter (point (s*arclength(p) + (ahlength/2)) on p) fi
enddef ;
+def resetarrows =
+ hide (
+ ahlength := 4 ;
+ ahangle := 45 ;
+ ahvariant := 0 ;
+ ahdimple := 1/5 ;
+ )
+enddef ;
+
%D Points.
def drawpoint expr c =
@@ -2811,4 +2820,17 @@ enddef;
extra_endfig := extra_endfig & "mfun_apply_max_dimensions ;" ;
+%D Bonus shapes (need along):
+
+path unittriangle, fulltriangle ; % not really units but circle based
+
+unittriangle := point 0 along unitcircle
+ -- point 1/3 along unitcircle
+ -- point 2/3 along unitcircle
+ -- cycle ;
+fulltriangle := point 0 along fullcircle
+ -- point 1/3 along fullcircle
+ -- point 2/3 along fullcircle
+ -- cycle ;
+
let dump = relax ;