summaryrefslogtreecommitdiff
path: root/metapost
diff options
context:
space:
mode:
authorContext Git Mirror Bot <phg42.2a@gmail.com>2015-01-08 15:15:04 +0100
committerContext Git Mirror Bot <phg42.2a@gmail.com>2015-01-08 15:15:04 +0100
commit1bda0d9ea4d65df72ed3382039a6d061c3e1073f (patch)
tree65b39c384edb595b5b62162bf8b8c1625248d665 /metapost
parent9f639e93850762b4169cbe7db9cfa7a8edb5a856 (diff)
downloadcontext-1bda0d9ea4d65df72ed3382039a6d061c3e1073f.tar.gz
2015-01-08 15:01:00
Diffstat (limited to 'metapost')
-rw-r--r--metapost/context/base/mp-grap.mpiv28
-rw-r--r--metapost/context/base/mp-tool.mpiv12
2 files changed, 29 insertions, 11 deletions
diff --git a/metapost/context/base/mp-grap.mpiv b/metapost/context/base/mp-grap.mpiv
index 6d2924c52..4fd8ee5bd 100644
--- a/metapost/context/base/mp-grap.mpiv
+++ b/metapost/context/base/mp-grap.mpiv
@@ -17,7 +17,10 @@ boolean context_grap ; context_grap := true ;
% Below is a modified graph.mp
-if epsilon/4 = 0 : % numbersystem="scaled" : (not reliable...)
+show numbersystem, numberprecision ;
+
+%if epsilon/4 = 0 :
+if numbersystem <> "double" :
errmessage "The graph macros require the double precision number system." ;
endinput ;
fi
@@ -75,7 +78,7 @@ newinternal mlogten ; mlogten := mlog(10) ;
newinternal largestmantissa ; largestmantissa := 2**52 ; % internal double warningcheck
newinternal singleinfinity ; singleinfinity := 2**128 ;
newinternal doubleinfinity ; doubleinfinity := 2**1024 ;
-Mzero := -largestmantissa ; % Note that we get arithmetic overflows if we set to -doubleinfinity
+%Mzero := -largestmantissa ; % Note that we get arithmetic overflows if we set to -doubleinfinity
% Safely convert a number to mlog form, trapping zero.
@@ -428,13 +431,15 @@ vardef graph_pair_adjust(expr p)(suffix tx, ty) = (tx xpart p, ty ypart p) endde
vardef graph_convert_user_path_to_internal primary p =
interim warningcheck :=0 ;
- graph_scan_path(p,
- (abs X_.graph_coordinate_type<>linear) or (abs Y_.graph_coordinate_type<>linear),
- if abs X_.graph_coordinate_type=log : graph_mlog fi,
- if abs Y_.graph_coordinate_type=log : graph_mlog fi)
- transformed (identity
- if X_.graph_coordinate_type<0 : xscaled -1 fi
- if Y_.graph_coordinate_type<0 : yscaled -1 fi)
+ if known p :
+ graph_scan_path(p,
+ (abs X_.graph_coordinate_type<>linear) or (abs Y_.graph_coordinate_type<>linear),
+ if abs X_.graph_coordinate_type=log : graph_mlog fi,
+ if abs Y_.graph_coordinate_type=log : graph_mlog fi)
+ transformed (identity
+ if X_.graph_coordinate_type<0 : xscaled -1 fi
+ if Y_.graph_coordinate_type<0 : yscaled -1 fi)
+ fi
enddef ;
% Convert label location t_ from user graph coords to internal graph coords.
@@ -520,10 +525,11 @@ enddef ;
% Execute c for each line of data read from file f, and stop at the first
% line with no data. Commands c can use line number i and tokens $1, $2, ...
+% and j is the number of fields.
def gdata(expr f)(suffix $)(text c) =
- boolean flag ;
- for i=1 upto infinity :
+ %boolean flag ; % not used?
+ for i=1 upto largestmantissa :
exitunless graph_read_line$(f) ;
c
endfor
diff --git a/metapost/context/base/mp-tool.mpiv b/metapost/context/base/mp-tool.mpiv
index f1d9ecaf6..6502720ad 100644
--- a/metapost/context/base/mp-tool.mpiv
+++ b/metapost/context/base/mp-tool.mpiv
@@ -2297,6 +2297,18 @@ vardef area expr p =
(xpart lrcorner boundingbox p,0) -- cycle
enddef ;
+vardef basiccolors[] =
+ save n ; n := @ mod 7 ;
+ if n = 1 : red
+ elseif n = 2 : green
+ elseif n = 3 : blue
+ elseif n = 4 : cyan
+ elseif n = 5 : magenta
+ elseif n = 6 : yellow
+ else : black
+ fi
+enddef ;
+
% vardef somecolor = (1,1,0,0) enddef ;