summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/metapost/context/base
diff options
context:
space:
mode:
authorMojca Miklavec <mojca.miklavec@gmail.com>2014-05-05 20:58:56 +0000
committerMojca Miklavec <mojca.miklavec@gmail.com>2014-05-05 20:58:56 +0000
commitb41cac6cebc8095cf8eaf7e84f8a2d5f63b7be38 (patch)
tree485b647339dff06549a9e6209d29f420cb6e1834 /Master/texmf-dist/metapost/context/base
parent28d5537add2c5bc2b860143edfa07d359d8ddec0 (diff)
ConTeXt 2014.05.05 22:31
git-svn-id: svn://tug.org/texlive/trunk@33858 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/metapost/context/base')
-rw-r--r--Master/texmf-dist/metapost/context/base/mp-chem.mpiv81
-rw-r--r--Master/texmf-dist/metapost/context/base/mp-grap.mpiv42
2 files changed, 90 insertions, 33 deletions
diff --git a/Master/texmf-dist/metapost/context/base/mp-chem.mpiv b/Master/texmf-dist/metapost/context/base/mp-chem.mpiv
index 2addb0a73ea..a316a1a30cb 100644
--- a/Master/texmf-dist/metapost/context/base/mp-chem.mpiv
+++ b/Master/texmf-dist/metapost/context/base/mp-chem.mpiv
@@ -24,7 +24,7 @@ numeric
chem_text_min, chem_text_max,
chem_rotation, chem_adjacent, chem_stack_n,
chem_substituent, chem_substituent.lft, chem_substituent.rt,
- chem_setting_offset, chem_text_offset, chem_picture_offset,
+ chem_setting_offset, chem_text_offset,
chem_center_offset, chem_dbl_offset,
chem_bb_angle, chem_axis_rulethickness,
chem_setting_l, chem_setting_r, chem_setting_t, chem_setting_b,
@@ -72,19 +72,18 @@ chem_axis_rulethickness := 1pt ;
chem_emwidth := 10pt ; % EmWidth or \the\emwidth does not work...
chem_b_length := 3 chem_emwidth ;
chem_text_offset := -.3chem_emwidth ; % -.71chem_emwidth ; % 1/sqrt(2)
-chem_center_offset := .5 chem_emwidth ;
-chem_picture_offset := chem_emwidth ;
+chem_center_offset := .5chem_emwidth ;
chem_dbl_offset := .05 ;
chem_bb_angle := angle(1,2chem_dbl_offset) ;
chem_text_min := 0.75 ;
chem_text_max := 1.25 ;
-chem_dot_factor := 4 ; % *linewidth
+chem_dot_factor := 2 ; % *linewidth
chem_sb_pair := (0.25,0.75) ; %chem_sb_dash := dashpattern(off 0.25 on 0.5 off 0.25) ;
chem_sb_pair.m := (0.25,1 ) ; %chem_sb_dash.m := dashpattern(off 0.25 on 0.75) ;
chem_sb_pair.p := (0 ,0.75) ; %chem_sb_dash.p := dashpattern(on 0.75 off 0.25) ;
-chem_sb_pair.b := (0, 1 ) ; %chem_sb_dash.b := dashpattern(on 1) ;
+chem_sb_pair.b := (0 ,1 ) ; %chem_sb_dash.b := dashpattern(on 1) ;
-chem_bd_wedge := false ; % true is incorrect, but quite common...
+chem_bd_wedge := true ; % according to IUPAC 2005
def chem_reset =
chem_rotation := 0 ;
@@ -149,7 +148,7 @@ vardef chem_init_some (suffix $) (expr e) =
chem_num2 := i ;
fi
endfor)
- scaled (2*(abs(point chem_num2+.5 of chem_b_path[$]) - chem_dbl_offset))
+ scaled (2*(abs(point chem_num2+.5 of chem_b_path[$]) - 2chem_dbl_offset))
fi ;
chem_r_path[$] :=
@@ -307,11 +306,15 @@ chem_init_all ; % WHY does this not work unless defined and then called?
% \startchemical
-def chem_start_structure(expr i, l, r, t, b, rotation, unit, factor, offset, axis, rulethickness, axiscolor) =
+def chem_start_structure(expr i, l, r, t, b, rotation, unit, bond, scale, offset, axis, rulethickness, axiscolor) =
save chem_setting_l, chem_setting_r, chem_setting_t, chem_setting_b ;
- chem_emwidth := unit ;
- chem_b_length := factor * unit ;
+ chem_emwidth := unit ; % dynamically set for each structure.
+ chem_text_offset := -.3chem_emwidth ; % -.71chem_emwidth ; % 1/sqrt(2)
+ chem_center_offset := .5chem_emwidth ;
+ chem_b_length := chem_emwidth * bond * scale ;
+ % scale (normally 1) scales the structure but not the text.
+
if numeric l :
chem_setting_l := -l ;
fi
@@ -798,28 +801,39 @@ vardef chem_eb@# (suffix $) (expr f, t, r, c) = % EB
enddef ;
vardef chem_ad@# (suffix $) (expr f, t, r, c) = % AD
- if not chem_star[$] :
- chem_t := identity chem_transformed($) ;
- for i=f upto t :
- chem_drawarrow(
- ((subpath (chem_sb_pair@# shifted (i-1,i-1)) of chem_b_path[$])
- paralleled 2chem_dbl_offset) transformed chem_t,
- r,c,) ;
- endfor
- fi
+ chem_t := identity chem_transformed($) ;
+ for i=f upto t :
+ chem_drawarrow(
+ (
+ (subpath
+ if chem_star[$] :
+ chem_sb_pair@# of chem_r_fragment($,i)
+ ) paralleled 5chem_dbl_offset
+ else :
+ (chem_sb_pair@# shifted (i-1,i-1)) of chem_b_path[$]
+ ) paralleled 2chem_dbl_offset
+ fi
+ ) transformed chem_t,
+ r,c,) ;
+ endfor
enddef ;
vardef chem_au@# (suffix $) (expr f, t, r, c) = % AU
- if not chem_star[$] :
- chem_t := identity chem_transformed($) ;
- for i=f upto t :
- chem_drawarrow(
- reverse(
- (subpath (chem_sb_pair@# shifted (i-1,i-1)) of chem_b_path[$])
- paralleled 2chem_dbl_offset) transformed chem_t,
- r,c,) ;
- endfor
- fi
+ chem_t := identity chem_transformed($) ;
+ for i=f upto t :
+ chem_drawarrow(
+ ((reverse
+ subpath
+ if chem_star[$] :
+ chem_sb_pair@# of chem_r_fragment($,i)
+ ) paralleled -5chem_dbl_offset
+ else :
+ (chem_sb_pair@# shifted (i-1,i-1)) of chem_b_path[$]
+ ) paralleled -2chem_dbl_offset
+ fi
+ ) transformed chem_t,
+ r,c,) ;
+ endfor
enddef ;
vardef chem_es@# (suffix $) (expr f, t, r, c) = % ES
@@ -1004,6 +1018,15 @@ enddef ;
vardef chem_hb@# (suffix $) (expr f, t, r, c) = % HB
if chem_star[$] :
chem_rh@#($,f,t,r,c)
+ else :
+ chem_t := identity chem_transformed($) ;
+ for i=f upto t :
+ chem_draw(
+ (subpath (chem_sb_pair@# shifted (i-1,i-1)) of chem_b_path[$])
+ transformed chem_t,
+ chem_dot_factor*r,c,dashed withdots scaled ((.5chem_b_length/3)/5bp)) ;
+ % not symmetric - needs to be tweaked...
+ endfor
fi
enddef ;
diff --git a/Master/texmf-dist/metapost/context/base/mp-grap.mpiv b/Master/texmf-dist/metapost/context/base/mp-grap.mpiv
index 6d69c0b1ed0..6d2924c5263 100644
--- a/Master/texmf-dist/metapost/context/base/mp-grap.mpiv
+++ b/Master/texmf-dist/metapost/context/base/mp-grap.mpiv
@@ -64,9 +64,9 @@ fi
% are of the form X_.<suffix>, Y_.<suffix>, or Z_.<suffix>, or they start
% with `graph_'
-% Depends on :
+% Used to depend on :
-input string.mp
+% input string.mp
% Private version of a few marith macros, fixed for double math...
@@ -467,16 +467,50 @@ enddef ;
% initial "%", and return true if at least one token is found. The tokens
% are stored in @#1, @#2, .. with "" in the last @#[] entry.
+% String manipulation routines for MetaPost
+% It is harmless to input this file more than once.
+
+vardef isdigit primary d =
+ ("0"<=d)and(d<="9")
+enddef ;
+
+% Number of initial characters of string s where `c <character>' is true
+
+vardef graph_cspan(expr s)(text c) =
+ 0
+ for i=1 upto length s:
+ exitunless c substring (i-1,i) of s;
+ + 1
+ endfor
+enddef ;
+
+% String s is composed of items separated by white space. Lop off the first
+% item and the surrounding white space and return just the item.
+
+vardef graph_loptok suffix s =
+ save t, k;
+ k = graph_cspan(s," ">=);
+ if k > 0 :
+ s := substring(k,infinity) of s ;
+ fi
+ k := graph_cspan(s," "<);
+ string t;
+ t = substring (0,k) of s;
+ s := substring (k,infinity) of s;
+ s := substring (graph_cspan(s," ">=),infinity) of s;
+ t
+enddef ;
+
vardef graph_read_line@#(expr f) =
save n_, s_ ; string s_;
s_ = readfrom f ;
string @#[] ;
if s_<>EOF :
@#0 := s_ ;
- @#1 := loptok s_ ;
+ @#1 := graph_loptok s_ ;
n_ = if @#1="%" : 0 else : 1 fi ;
forever :
- @#[incr n_] := loptok s_ ;
+ @#[incr n_] := graph_loptok s_ ;
exitif @#[n_]="" ;
endfor
@#1<>""