summaryrefslogtreecommitdiff
path: root/metapost
diff options
context:
space:
mode:
Diffstat (limited to 'metapost')
-rw-r--r--metapost/context/base/metafun.mpii1
-rw-r--r--metapost/context/base/metafun.mpiv1
-rw-r--r--metapost/context/base/mp-form.mpii (renamed from metapost/context/base/mp-form.mp)0
-rw-r--r--metapost/context/base/mp-form.mpiv24
-rw-r--r--metapost/context/base/mp-func.mpiv22
-rw-r--r--metapost/context/base/mp-grid.mpiv38
6 files changed, 46 insertions, 40 deletions
diff --git a/metapost/context/base/metafun.mpii b/metapost/context/base/metafun.mpii
index 783b467dc..374ad88d0 100644
--- a/metapost/context/base/metafun.mpii
+++ b/metapost/context/base/metafun.mpii
@@ -41,6 +41,7 @@ input "mp-char.mpii" ;
input "mp-step.mpii" ;
input "mp-grph.mpii" ;
input "mp-figs.mpii" ;
+input "mp-form.mpii" ;
input "mp-grid.mpii" ;
input "mp-func.mpii" ;
diff --git a/metapost/context/base/metafun.mpiv b/metapost/context/base/metafun.mpiv
index 4bc762cf7..13dcc85c8 100644
--- a/metapost/context/base/metafun.mpiv
+++ b/metapost/context/base/metafun.mpiv
@@ -25,6 +25,7 @@ input "mp-butt.mpiv" ; % todo: namespace and cleanup
input "mp-shap.mpiv" ; % will be improved
input "mp-grph.mpiv" ; % todo: namespace and cleanup
input "mp-grid.mpiv" ; % todo: namespace and cleanup
+input "mp-form.mpiv" ; % under (re)construction
input "mp-figs.mpiv" ; % obsolete, needs checking
input "mp-text.mpiv" ; % will be redone into a module
diff --git a/metapost/context/base/mp-form.mp b/metapost/context/base/mp-form.mpii
index 60ea4cac2..60ea4cac2 100644
--- a/metapost/context/base/mp-form.mp
+++ b/metapost/context/base/mp-form.mpii
diff --git a/metapost/context/base/mp-form.mpiv b/metapost/context/base/mp-form.mpiv
new file mode 100644
index 000000000..8a7ceac16
--- /dev/null
+++ b/metapost/context/base/mp-form.mpiv
@@ -0,0 +1,24 @@
+%D \module
+%D [ file=mp-form.mp,
+%D version=2011.10.14,
+%D title=\CONTEXT\ \METAPOST\ graphics,
+%D subtitle=form support,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA / Hans Hagen \& Ton Otten}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See licen-en.pdf for
+%C details.
+
+% The graph package will be replaced by our own variant using
+% MetaPost 2 features and textext.
+
+% The following function accept a number or string that can be
+% converted to a number by \LUA. The first argument is a format
+% where @ can be used instead of %. The number is typeset in math
+% mode and @3e is converted into @.3e.
+
+vardef mfun_format_number(expr fmt, i) =
+ "\ctxlua{metapost.formatnumber('" & fmt & "'," & if string i : i else : decimal i fi & ")}"
+enddef
diff --git a/metapost/context/base/mp-func.mpiv b/metapost/context/base/mp-func.mpiv
index 6ce7ee82a..26037f48c 100644
--- a/metapost/context/base/mp-func.mpiv
+++ b/metapost/context/base/mp-func.mpiv
@@ -24,7 +24,10 @@ mfun_pathconnectors[1] := "--" ;
mfun_pathconnectors[2] := ".." ;
mfun_pathconnectors[3] := "..." ;
-vardef mfun_draw_function (expr f) (expr u, t, b, e, s) = save x ; numeric x ;
+def pathconnectors = mfun_pathconnectors enddef ;
+
+vardef mfun_function (expr f) (expr u, t, b, e, s) =
+ save x ; numeric x ;
for xx := b step s until e :
hide (x := xx ;)
if xx > b :
@@ -34,6 +37,7 @@ vardef mfun_draw_function (expr f) (expr u, t, b, e, s) = save x ; numeric x ;
endfor
enddef ;
+def function = mfun_function enddef ; % let doesn't work here
def punkedfunction = mfun_function (1) enddef ;
def curvedfunction = mfun_function (2) enddef ;
def tightfunction = mfun_function (3) enddef ;
@@ -50,9 +54,10 @@ vardef mfun_constructedpath (expr f) (text t) =
endfor
enddef ;
-def punkedpath = mfun_constructedpath (1) enddef ;
-def curvedpath = mfun_constructedpath (2) enddef ;
-def tightpath = mfun_constructedpath (3) enddef ;
+def constructedpath = mfun_constructedpath enddef ; % let doesn't work here
+def punkedpath = mfun_constructedpath (1) enddef ;
+def curvedpath = mfun_constructedpath (2) enddef ;
+def tightpath = mfun_constructedpath (3) enddef ;
vardef mfun_constructedpairs (expr f) (text p) =
save i ; i := -1 ;
@@ -65,6 +70,9 @@ vardef mfun_constructedpairs (expr f) (text p) =
endfor
enddef ;
-def punkedpairs = mfun_constructedpairs (1) enddef ;
-def curvedpairs = mfun_constructedpairs (2) enddef ;
-def tightpairs = mfun_constructedpairs (3) enddef ;
+def constructedpairs = mfun_constructedpairs enddef ; % let doesn't work here
+def punkedpairs = mfun_constructedpairs (1) enddef ;
+def curvedpairs = mfun_constructedpairs (2) enddef ;
+def tightpairs = mfun_constructedpairs (3) enddef ;
+
+
diff --git a/metapost/context/base/mp-grid.mpiv b/metapost/context/base/mp-grid.mpiv
index ee8f2489d..6cb98466e 100644
--- a/metapost/context/base/mp-grid.mpiv
+++ b/metapost/context/base/mp-grid.mpiv
@@ -65,36 +65,32 @@ enddef ;
vardef hlintext@#(expr Min, Max, Step, Length, Format) text t =
image (
- do_initialize_numbers ;
for i=Min step Step until Max+grid_eps :
- draw textext@#(do_format(Format,i)) shifted (0,i*(Length/Max)) t ;
+ draw textext@#(mfun_format_number(Format,i)) shifted (0,i*(Length/Max)) t ;
endfor ;
)
enddef ;
vardef vlintext@#(expr Min, Max, Step, Length, Format) text t =
image (
- do_initialize_numbers ;
for i=Min step Step until Max+grid_eps :
- draw textext@#(do_format(Format,i)) shifted (i*(Length/Max),0) t ;
+ draw textext@#(mfun_format_number(Format,i)) shifted (i*(Length/Max),0) t ;
endfor ;
)
enddef ;
vardef hlogtext@#(expr Min, Max, Step, Length, Format) text t =
image (
- do_initialize_numbers ;
for i=max(Min,1) step Step until min(Max,10)+grid_eps :
- draw textext@#(do_format(Format,i)) shifted (0,Length*log(i)) t ;
+ draw textext@#(mfun_format_number(Format,i)) shifted (0,Length*log(i)) t ;
endfor ;
)
enddef ;
vardef vlogtext@#(expr Min, Max, Step, Length, Format) text t =
image (
- do_initialize_numbers ;
for i=max(Min,1) step Step until min(Max,10)+grid_eps :
- draw textext@#(do_format(Format,i)) shifted (Length*log(i),0) t ;
+ draw textext@#(mfun_format_number(Format,i)) shifted (Length*log(i),0) t ;
endfor ;
)
enddef ;
@@ -115,31 +111,6 @@ vardef vlinlabel@#(expr Min, Max, Step, Length) text t =
)
enddef ;
-boolean numbers_initialized ; numbers_initialized := false ;
-
-def do_initialize_numbers =
- if not numbers_initialized :
- init_numbers (
- textext.raw("$-$") ,
- textext.raw("$1$") ,
- textext.raw("${\times}10$") ,
- textext.raw("${}^-$") ,
- textext.raw("${}^2$")
- ) ;
- if unknown _trial_run_ :
- numbers_initialized := true ;
- else :
- % no reset, otherwise textexts get out of sync
- % slows down graphics a bit but not much
- fi ;
- fi ;
-enddef ;
-
-def initialize_numbers =
- numbers_initialized := false ;
- do_initialize_numbers ;
-enddef ;
-
vardef linlog(expr xy) = ( xpart xy, log(ypart xy)) enddef ;
vardef loglin(expr xy) = (log(xpart xy), ypart xy) enddef ;
vardef loglog(expr xy) = (log(xpart xy), log(ypart xy)) enddef ;
@@ -168,3 +139,4 @@ vardef processpath (expr p) (text pp) =
p
fi
enddef ;
+