summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/metapost
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2017-02-13 23:21:29 +0000
committerKarl Berry <karl@freefriends.org>2017-02-13 23:21:29 +0000
commit03c75645664be34a27afa8e4e30b0f96d25de53b (patch)
tree321e76e87bf34314014a157b7a05df2c24acb223 /Master/texmf-dist/metapost
parent90e1a28c9221e47cec2a912b5551d2f6522735ad (diff)
mcf2graph (13feb17)
git-svn-id: svn://tug.org/texlive/trunk@43218 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/metapost')
-rw-r--r--Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf100
1 files changed, 70 insertions, 30 deletions
diff --git a/Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf b/Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf
index 7fa4db15f74..c2d6f991841 100644
--- a/Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf
+++ b/Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf
@@ -1,5 +1,5 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% mcf2graph ver 4.09 Copyright (c) 2013-2017 Akira Yamaji
+% mcf2graph ver 4.10 Copyright (c) 2013-2017 Akira Yamaji
%
% Permission is hereby granted, free of charge, to any person obtaining a copy of this software
% and associated documentation files (the "Software"), to deal in the Software without restriction,
@@ -30,7 +30,7 @@
% Set output report : mpost -s ahlength=2 FILENAME
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
tracingstats:=1;
-message " This is mcf2graph ver 4.0 2017.1";
+message " This is mcf2graph ver 4.1 2017.2";
%-------------------------------------------------------------------------------------------------
newinternal nA,nB,nC,nD,nE,nF,char_num,str_cnt,def_num,def_int,tbl_cnt;
numeric save_para[],comD[][],parD[][],cntD[],tbl_str_wd[],tbl_atom[],tbl_subst[][],tbl_atom_wt[],
@@ -39,8 +39,8 @@ string tbl_atom_str[],strD[],var[],tag[],mp_log_name,aux_delimiter;
picture atom_font[],str_font[],mol_stru[],save_pict;
%-------------------------------------------------------------------------------------------------
char_num:=str_cnt:=proc_end:=0;
-sw_numberA:=sw_numberB:=sw_mol_frame:=sw_auxout:=sw_solid:=sw_expand:=sw_font_frame:=0;
-sw_atom_frame:=sw_report:=sw_MOLout:=sw_subst_off:=sw_bond_single:=sw_auxfix:=sw_clip:=0;
+sw_numberA:=sw_numberB:=sw_mol_frame:=sw_auxout:=sw_solid:=sw_expand:=sw_font_frame:=sw_clip:=0;
+sw_atom_frame:=sw_report:=sw_MOLout:=sw_subst_off:=sw_bond_single:=sw_auxfix:=sw_label_mp:=0;
numberA_start:=numberB_start:=1; numberA_end:=numberB_end:=4095; aux_max:=max_inf_num:=20;
aux_delimiter:=";"; var1:="jobname"; tag1:="F"; var2:="char_num"; tag2:="C";
for i=3 upto aux_max: var[i]:=tag[i]:=""; endfor
@@ -63,9 +63,13 @@ if (known green)and(known ahlength):
def # = enddef;
def Cp(expr s) = if known s: if s<>0: withcolor color_list[s] fi fi enddef;
def define_pixels(text s) = enddef;
+ if sw_label_mp=0: def label = label_ext enddef; fi
else: f_MP:=0;
- def Cp(expr s) = enddef; def color = transform enddef;
- mode_setup; def printf expr s= message s enddef;
+ def Cp(expr s) = enddef;
+ def color = transform enddef;
+ def label = label_ext enddef;
+ def printf expr s= message s enddef;
+ mode_setup;
fi
ahangle:=45; ahlength:=4;
clearit;
@@ -80,7 +84,9 @@ ratio_char_bond:=1.5; ratio_bondgap_bond:=0.15; ratio_zebragap_bond:=0.
ratio_zebra_black:=0.4; ratio_wedge_bond:=0.12; ratio_atomgap_atom:=0.050;
offset_thickness#:=0.2pt#; offset_bond_gap#:=0.3pt#; offset_zebra_gap#:=0.1pt#;
offset_atom#:=0.8pt#; offset_wedge#:=0.4pt#; thickness_font_frame#:=0.2pt#;
-max_bond_length#:=10mm; bond_len#:=8mm#; font_wd#:=30mm#; font_ht#:=20mm#;
+max_bond_length#:=10mm; bond_len#:=8mm#;
+font_wd#:=30mm#; font_ht#:=20mm#;
+labeloffset:=3bp; default_emb_font#:=5pt#;
%--------------------------------------------------------------------------------------------------
def_emb_start:=500; % 500 => 2499 for embedded definition (max 2000)
def_usr_start:=2500; % 2500 => 2999 for user definition (max 500)
@@ -95,10 +101,10 @@ def_com(1)(si,dl,dr,db,dm,tm,wf,wb,bd,bz,zf,zb,dt,wv,nl,vf,vb,si_,wf_,wb_,bd_);
%--------------------------------------------------------------------------------------------------
def parameter_list=
sw_report,sw_numberA,sw_numberB,sw_mol_frame,sw_auxout,sw_solid,sw_expand,sw_MOLout,
- sw_atom_frame,sw_font_frame,sw_subst_off,sw_bond_single,sw_clip,
+ sw_atom_frame,sw_font_frame,sw_subst_off,sw_bond_single,sw_clip,sw_label_mp,
margin_left_right,margin_top_bottom,ratio_atom_bond,ratio_thickness_bond,ratio_char_bond,
ratio_chain_ring,max_bond_width,ratio_bondgap_bond,ratio_zebra_black,ratio_zebragap_bond,
- ratio_wedge_bond,ratio_atomgap_atom,ratio_bond_width,font_wd#,font_ht#,
+ ratio_wedge_bond,ratio_atomgap_atom,ratio_bond_width,font_wd#,font_ht#,labeloffset,
bond_len#,offset_atom#,offset_wedge#,max_bond_length#,offset_zebra_gap#,offset_bond_gap#,
thickness_font_frame#,offset_thickness#,numberA_start,numberA_end,numberB_start,numberB_end
enddef;
@@ -302,9 +308,13 @@ enddef;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
def EXT(text s)=
begingroup
- save w,h,wd,ht,n,p; pair p[];
+ save w,h,wd,ht,n,p,em;
+ pair p[];
+ use_font(default_emb_font#);
w:=font_wd; h:=font_ht; wd:=w-2margin_left_right; ht:=h-2margin_top_bottom;
- p0:=(margin_left_right,margin_top_bottom); n:=cntM;
+ p0:=(margin_left_right,margin_top_bottom);
+ em:=emb_font_size;
+ n:=cntM;
for i=1 upto n: p[i]:=posM[1][i]; endfor
s addto mol_stru[0] also currentpicture; clearit; f_ext:=1;
endgroup;
@@ -312,18 +322,28 @@ enddef;
%--------------------------------------------------------------------------------------------------
def ext(text s)=
begingroup
- save wd,ht,n,a,l,p; numeric a[]; pair p[]; wd:=mol_wd; ht:=mol_ht; l:=bond_len;
- p0:=(minX,minY); n:=cntA; for i=1 upto n: p[i]:=posA[i]; a[i]:=ang_br[i]; endfor
+ save wd,ht,n,l,p,zw,sp,ep,em,A,B;
+ numeric A[]bra,B[]ang;
+ pair p[],A[],B[],sp,ep;
+ use_font(default_emb_font#);
+ wd:=mol_wd;
+ ht:=mol_ht;
+ l:=bond_len;
+ em:=emb_font_size;
+ p0:=(minX,minY);
+ An:=cntA; Bn:=cntB;
+ for i=1 upto An: A[i]:=posA[i]; A[i]bra:=ang_br[i]; endfor
+ for i=1 upto Bn: sp:=posA[sB[i]]; ep:=posA[eB[i]]; B[i]:=0.5[sp,ep]; B[i]ang:=angB[i]; endfor
s addto mol_stru[cntM] also currentpicture; clearit;
endgroup;
enddef;
%--------------------------------------------------------------------------------------------------
def use_font(expr WD)=
- save_pict:=currentpicture;
+ save_pict:=currentpicture; clearit;
for i=1 upto 128: f_char[i]:=1; endfor
proc_char_setup(str_font)(WD);
- str_wd#:=WD;
- define_pixels(str_wd);
+ emb_font_size#:=WD;
+ define_pixels(emb_font_size);
currentpicture:=save_pict;
enddef;
%--------------------------------------------------------------------------------------------------
@@ -333,11 +353,35 @@ def puts(expr PA)(expr STR)=
cp:=PA;
for i=0 upto length(STR)-1:
nA:=ASCII(pic_c(i,STR));
- addto currentpicture also str_font[nA] shifted (cp-(0,str_wd*tbl_char_dp[nA]));
- cp:=cp+(str_wd*tbl_char_wd[nA],0);
+ addto currentpicture also str_font[nA] shifted (cp-(0,emb_font_size*tbl_char_dp[nA]));
+ cp:=cp+(emb_font_size*tbl_char_wd[nA],0);
endfor
endgroup;
enddef;
+%--------------------------------------------------------------------------------------------------
+vardef label_ext@#(expr STR,POS) =
+ save oft,fx,fy,wds;
+ pair oft,oft.lft,oft.rt,oft.top,oft.bot,oft.ulft,oft.llft,oft.urt,oft.lrt;
+ wds:=0;
+ for i=0 upto length(STR)-1:
+ wds:=wds+emb_font_size*tbl_char_wd[ASCII(pic_c(i,STR))];
+ endfor
+ oft:= ( 0, 0); fx:=0.5; fy:=0.5;
+ oft.lft:= ( -1, 0); fx.lft:=1; fy.lft:=0.5;
+ oft.rt := ( 1, 0); fx.rt :=0; fy.rt :=0.5;
+ oft.bot:= ( 0, -1); fx.bot:=0.5; fy.bot:=1;
+ oft.top:= ( 0, 1); fx.top:=0.5; fy.top:=0;
+ oft.ulft:=(-.7, .7); fx.ulft:=1; fy.ulft:=0;
+ oft.urt:= ( .7, .7); fx.urt:=0; fy.urt:=0;
+ oft.llft:=(-.7,-.7); fx.llft:=1; fy.llft:=1;
+ oft.lrt:= ( .7,-.7); fx.lrt:=0; fy.lrt:=1;
+ puts(POS+(labeloffset*oft@#)-(wds*fx@#,emb_font_size*fy@#))(STR);
+enddef;
+%-------------------------------------------------------------------------------------------------
+def draw_vector(expr POS,ROT,THICK,LEN)=
+ fill (-2mm,-(.5THICK+.4mm))--(0,0)--(-2mm,.5THICK+.4mm)--(-2mm,.5THICK)--(-LEN,.5THICK)--
+ (-LEN,-.5THICK)--(-2mm,-.5THICK)--cycle rotated ROT shifted POS;
+enddef;
%=================================================================================================
def MCf(text s)= MCd(1,1)(.5,.5)(s) enddef; % MC fill draw
%-------------------------------------------------------------------------------------------------
@@ -441,11 +485,6 @@ def draw_corner(expr LX,LY,PN)=
drawdot(0,0) wpss PN; drawdot(LX,0) wpss PN; drawdot(LX,LY) wpss PN; drawdot(0,LY) wpss PN;
enddef;
%-------------------------------------------------------------------------------------------------
-def draw_vector(expr POS,ROT,LEN)=
- fill (-2mm,-1mm)--(0,0)--(-2mm,1mm)--(-2mm,.4mm)--(-LEN,.4mm)--
- (-LEN,-.4mm)--(-2mm,-.4mm)--cycle rotated ROT shifted POS;
-enddef;
-%-------------------------------------------------------------------------------------------------
def proc_size_setup=
if (bond_len#*ratio_atom_bond+offset_atom#)<.8bond_len#:
atom_wd#:=bond_len#*ratio_atom_bond+offset_atom#;
@@ -803,8 +842,9 @@ enddef;
%---------------------------------------------------------------
char_size_set( 1)( 1)( 0)("CGHMNOQ");
char_size_set(.9)( 1)( 0)("ABDEFIJKLPRSTUVWXYZ-+/><m");
-char_size_set(.7)( 1)( 0)(" ()0123456789nhj=*bdiltf");
-char_size_set(.7)( 1)(.15)("pqg");
+char_size_set(.7)( 1)( 0)(" ()0123456789nhj=*bdtf");
+char_size_set(.5)( 1)( 0)("il");
+char_size_set(.7)( 1)(.24)("pqg");
char_size_set(.7)(.8)( 0)("acekosuvxzwry");
char_size_set(.4)( 1)( 0)(".,:;'`");
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -862,7 +902,7 @@ FD("5")(draw Z12--Z16 hL; draw Z13--(hP,.49aH) vL;
FD("6")(draw Z19..(fW,.5fW)..(hW,fW)..(hP,.5fW)..cycle; cutdraw (hP,.4aH)--Z06);
FD("7")(draw (0,.fH)--Z16 hL; draw (aW-1.2hP,aH-fP)--(.4aW,0) vL scaled 1.2);
FD("8")(draw POh; draw (hP,.75aH)...Z14...(fW,.75aH)...Z20...cycle;);
-FD("9")(draw Z19..(fW,.5fW)..(hW,fW)..(hP,.5fW)..cycle sH .32aH; cutdraw (fW,.6aH)--Z07);
+FD("9")(draw (Z19..(fW,.5fW)..(hW,fW)..(hP,.5fW)..cycle) sH .32aH; cutdraw (fW,.6aH)--Z07);
FD("A")(draw Z02--Z06--Z05 vL scaled 1.14; draw .33[Z02,Z06]--.33[Z05,Z06]);
FD("B")(draw Z13--Z14{right}..(.9fH,.75aH)..{left}(.5aW,hH)--Z09--(.5aW,hH){right}..
(.9fH,.25aH)..{left}Z19--Z03; draw Z02--Z18 vL);
@@ -901,7 +941,7 @@ FD("c")(cutdraw SP(.06,.94)Z10..Z14..Z09..Z19..cycle);
FD("d")(draw Z19..Z10..Z11..Z09..cycle; draw Z05--(fW,1.2aH) vL);
FD("e")(cutdraw SP(0,.92)Z10..Z14..Z09..Z19..cycle; draw Z10--Z09);
FD("f")(cutdraw (.5aW,0)--(.5aW,.75aH){up}..(.75aW,fH)..{down}(fW,.8aH); draw Z08--Z17 hL);
-FD("g")(draw Z19..Z10..Z11..Z09..cycle sH .3aH; cutdraw Z15--(fW,hP)..(hW,0)..(.1aW,fP));
+FD("g")(draw (Z19..Z10..Z11..Z09..cycle) sH .3aH; cutdraw Z15--(fW,hP)..(hW,0)..(.1aW,fP));
FD("h")(draw Z02..(hP,.3aH){up}..(hW,.7fH)..{down}(fW,.3aH)..Z05; draw (hP,.3aH)--Z18 vL);
FD("i")(draw Z07--(hW,.63aH) vL; draw Z14 wpcs 1.4fP);
FD("j")(draw Z19--(hW,.63aH) vL; draw Z19..(.25aW,-hP)..Z01; draw Z14 wpcs 1.4fP);
@@ -911,9 +951,9 @@ FD("m")(cutdraw Z02..(hP,.3aH){up}..(.28aW,.7fH)..{down}(hW,.3aH)..Z07;
cutdraw (hW,.3aH){up}..(.7aW,.7aH-hP)..{down}(fW,.3aH)..Z05; draw (hP,.3aH)--(hP,.7aH) vL);
FD("n")(cutdraw Z02..(hP,.3aH){up}..(hW,.7fH)..{down}(fW,.3aH)..Z05; draw (hP,.3aH)--(hP,.7aH) vL);
FD("o")(draw Z19..Z10..Z14..Z09..cycle);
-FD("p")(draw Z19..Z10..Z11..Z09..cycle sH .3aH; draw (hP,0)--Z18 vL);
-FD("q")(draw Z19..Z10..Z11..Z09..cycle sH .3aH; draw (fW,0)--Z15 vL);
-FD("r")(cutdraw SP(.35,.72)Z19..Z10..Z14..Z09..cycle sH -fP; draw Z02--Z18 vL);
+FD("p")(draw (Z19..Z10..Z11..Z09..cycle) sH .3aH; draw (hP,0)--Z18 vL);
+FD("q")(draw (Z19..Z10..Z11..Z09..cycle) sH .3aH; draw (fW,0)--Z15 vL);
+FD("r")(cutdraw (SP(.35,.72)Z19..Z10..Z14..Z09..cycle) sH -fP; draw Z02--Z18 vL);
FD("s")(cutdraw SP(.05,.45)PO; cutdraw SP(.55,.95)PO; draw (fW,.3aH){up}..{up}(hP,.7aH));
FD("t")(draw Z07--Z06 vL; draw (0,.66aH)--(aW,.66aH) hL);
FD("u")(cutdraw Z18..(hP,.55aH){down}..Z19..(fW,.55aH){up}..Z15; draw Z15--Z05 vL);