summaryrefslogtreecommitdiff
path: root/metapost
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2002-01-24 00:00:00 +0100
committerHans Hagen <pragma@wxs.nl>2002-01-24 00:00:00 +0100
commit492154026fb3d8fa46a58ed89edce6a596e341ad (patch)
tree9b3d47bea73c10d7a85efcf9b55bd7f6e93ef4a8 /metapost
parent736de6a312c37fbb8cea65cf0a86eda7dbbe0575 (diff)
downloadcontext-492154026fb3d8fa46a58ed89edce6a596e341ad.tar.gz
stable 2002.01.24
Diffstat (limited to 'metapost')
-rw-r--r--metapost/context/mp-page.mp2
-rw-r--r--metapost/context/mp-spec.mp65
-rw-r--r--metapost/context/mp-tool.mp51
3 files changed, 85 insertions, 33 deletions
diff --git a/metapost/context/mp-page.mp b/metapost/context/mp-page.mp
index 285f84c41..679b02ec6 100644
--- a/metapost/context/mp-page.mp
+++ b/metapost/context/mp-page.mp
@@ -38,6 +38,7 @@ PrintPaperHeight := 845.04684pt ;
PrintPaperWidth := 597.50787pt ;
TopSpace := 71.12546pt ;
BackSpace := 71.13275pt ;
+CutSpace := 0.0pt ;
MakeupHeight := 711.3191pt ;
MakeupWidth := 426.78743pt ;
TopHeight := 0.0pt ;
@@ -101,6 +102,7 @@ endfor ;
def SwapPageState =
if not OnRightPage :
BackSpace := PaperWidth-MakeupWidth-BackSpace ;
+ CutSpace := PaperWidth-MakeupWidth-CutSpace ;
i := LeftMarginWidth ;
LeftMarginWidth := RightMarginWidth ;
RightMarginWidth := i ;
diff --git a/metapost/context/mp-spec.mp b/metapost/context/mp-spec.mp
index a8dfb96b6..1ec8164bc 100644
--- a/metapost/context/mp-spec.mp
+++ b/metapost/context/mp-spec.mp
@@ -76,35 +76,84 @@ extra_endfig :=
" reset_extra_specials ; " &
" insidefigure := false ; " ;
-def _current_specials_ =
- if insidefigure : _local_specials_ else : _global_specials_ fi
+def set_extra_special (expr s) =
+ if insidefigure :
+ _local_specials_ := _local_specials_ & s ;
+ else :
+ _global_specials_ := _global_specials_ & s ;
+ fi
enddef ;
def flush_special (expr typ, siz, dat) =
_special_counter_ := _special_counter_ + 1 ;
if _inline_specials_ :
- _current_specials_ := _current_specials_
- & "special "
+ set_extra_special
+ ( "special "
& "(" & ditto
& dat & " "
& decimal _special_counter_ & " "
& decimal typ & " "
& decimal siz
& " special"
- & ditto & ");" ;
+ & ditto & ");" ) ;
else :
- _current_specials_ := _current_specials_
- & "special "
+ set_extra_special
+ ( "special "
& "(" & ditto
& "%%MetaPostSpecial: "
& decimal siz & " "
& dat & " "
& decimal _special_counter_ & " "
& decimal typ
- & ditto & ");" ;
+ & ditto & ");" ) ;
fi ;
enddef ;
+%D The next hack is needed in case you use a version of
+%D \METAPOST\ that does not provide you the means to configure
+%D the buffer size. Patrick Gundlach suggested to use arrays
+%D in this case.
+
+boolean bufferhack ; bufferhack := false ; % true ;
+
+if bufferhack :
+
+ string _global_specials_[] ; numeric _nof_global_specials_ ;
+ string _local_specials_[] ; numeric _nof_local_specials_ ;
+
+ _nof_global_specials_ := _nof_local_specials_ := 0 ;
+
+ vardef add_special_signal = % write the version number
+ if (_nof_global_specials_>0) or (_nof_local_specials_>0) :
+ special ("%%MetaPostSpecials: 1.0 " & decimal _special_signal_ ) ;
+ fi ;
+ enddef ;
+
+ vardef add_extra_specials =
+ for i=1 upto _nof_global_specials_ :
+ scantokens _global_specials_[i] ;
+ endfor;
+ for i=1 upto _nof_local_specials_ :
+ scantokens _local_specials_[i] ;
+ endfor;
+ enddef ;
+
+ vardef reset_extra_specials =
+ string _local_specials_[] ; _nof_local_specials_ := 0 ;
+ enddef ;
+
+ def set_extra_special (expr s) =
+ if insidefigure :
+ _local_specials_[incr(_nof_local_specials_)] := s ;
+ else :
+ _global_specials_[incr(_nof_global_specials_)] := s ;
+ fi
+ enddef ;
+
+fi ;
+
+%D So far for this hack.
+
%D Shade allocation.
vardef define_linear_shade (expr a, b, ca, cb) =
diff --git a/metapost/context/mp-tool.mp b/metapost/context/mp-tool.mp
index d259a240c..95a89bf54 100644
--- a/metapost/context/mp-tool.mp
+++ b/metapost/context/mp-tool.mp
@@ -225,42 +225,43 @@ enddef;
numeric Pi ; Pi := 3.1415926 ;
-def sqr (expr x) = (x*x) enddef ;
-def log (expr x) = (if x=0: 0 else: mlog(x)/mlog(10) fi) enddef ;
-def ln (expr x) = (if x=0: 0 else: mlog(x)/256 fi) enddef ;
-def exp (expr x) = ((mexp 256)**x) enddef ;
-def inv (expr x) = (if x=0: 0 else: x**-1 fi) enddef ;
+vardef sqr primary x = (x*x) enddef ;
+vardef log primary x = (if x=0: 0 else: mlog(x)/mlog(10) fi) enddef ;
+vardef ln primary x = (if x=0: 0 else: mlog(x)/256 fi) enddef ;
+vardef exp primary x = ((mexp 256)**x) enddef ;
+vardef inv primary x = (if x=0: 0 else: x**-1 fi) enddef ;
-def pow (expr x,p) = (x**p) enddef ;
+vardef pow (expr x,p) = (x**p) enddef ;
-def asin (expr x) = (x+(x**3)/6+3(x**5)/40) enddef ;
-def acos (expr x) = (asin(-x)) enddef ;
-def atan (expr x) = (x-(x**3)/3+(x**5)/5-(x**7)/7) enddef ;
-def tand (expr x) = (sind(x)/cosd(x)) enddef ;
+vardef asin primary x = (x+(x**3)/6+3(x**5)/40) enddef ;
+vardef acos primary x = (asin(-x)) enddef ;
+vardef atan primary x = (x-(x**3)/3+(x**5)/5-(x**7)/7) enddef ;
+vardef tand primary x = (sind(x)/cosd(x)) enddef ;
-%D Here are Taco Hoekwater's alternatives:
+%D Here are Taco Hoekwater's alternatives (but
+%D vardef'd and primaried).
pi := 3.1415926 ; radian := 180/pi ; % 2pi*radian = 360 ;
-def tand (expr x) = (sind(x)/cosd(x)) enddef ;
-def cotd (expr x) = (cosd(x)/sind(x)) enddef ;
+vardef tand primary x = (sind(x)/cosd(x)) enddef ;
+vardef cotd primary x = (cosd(x)/sind(x)) enddef ;
-def sin (expr x) = (sind(x*radian)) enddef ;
-def cos (expr x) = (cosd(x*radian)) enddef ;
-def tan (expr x) = (sin(x)/cos(x)) enddef ;
-def cot (expr x) = (cos(x)/sin(x)) enddef ;
+vardef sin primary x = (sind(x*radian)) enddef ;
+vardef cos primary x = (cosd(x*radian)) enddef ;
+vardef tan primary x = (sin(x)/cos(x)) enddef ;
+vardef cot primary x = (cos(x)/sin(x)) enddef ;
-def asin (expr x) = angle((1+-+x,x)) enddef ;
-def acos (expr x) = angle((x,1+-+x)) enddef ;
+vardef asin primary x = angle((1+-+x,x)) enddef ;
+vardef acos primary x = angle((x,1+-+x)) enddef ;
-def invsin (expr x) = ((asin(x))/radian) enddef ;
-def invcos (expr x) = ((acos(x))/radian) enddef ;
+vardef invsin primary x = ((asin(x))/radian) enddef ;
+vardef invcos primary x = ((acos(x))/radian) enddef ;
-def acosh (expr x) = ln(x+(x+-+1)) enddef ;
-def asinh (expr x) = ln(x+(x++1)) enddef ;
+vardef acosh primary x = ln(x+(x+-+1)) enddef ;
+vardef asinh primary x = ln(x+(x++1)) enddef ;
-vardef sinh primary x = save xx ; xx = exp xx ; (xx-1/xx)/2 enddef ;
-vardef cosh primary x = save xx ; xx = exp xx ; (xx+1/xx)/2 enddef ;
+vardef sinh primary x = save xx ; xx = exp xx ; (xx-1/xx)/2 enddef ;
+vardef cosh primary x = save xx ; xx = exp xx ; (xx+1/xx)/2 enddef ;
%D We provide two macros for drawing stripes across a shape.
%D The first method (with the n suffix) uses another method,