diff options
author | Karl Berry <karl@freefriends.org> | 2006-09-27 18:11:21 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2006-09-27 18:11:21 +0000 |
commit | e95557faa7717d1933720a2cda89a99c6aab1dd7 (patch) | |
tree | c1867e637598f20d71977e893a6bf29ad95c1483 /Master/texmf-dist/metapost | |
parent | c31daf21a745dc6c14ad116918ba562d16727493 (diff) |
exteps update (27sep06)
git-svn-id: svn://tug.org/texlive/trunk@2208 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/metapost')
-rw-r--r-- | Master/texmf-dist/metapost/exteps/exteps.mp | 141 |
1 files changed, 100 insertions, 41 deletions
diff --git a/Master/texmf-dist/metapost/exteps/exteps.mp b/Master/texmf-dist/metapost/exteps/exteps.mp index 0ec3626f26b..fafd0abd3fa 100644 --- a/Master/texmf-dist/metapost/exteps/exteps.mp +++ b/Master/texmf-dist/metapost/exteps/exteps.mp @@ -1,4 +1,4 @@ -% Copyright 2005 by Palle Jørgensen +% Copyright 2005, 2006 by Palle Jorgensen % % This file is free software; you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by @@ -15,11 +15,14 @@ % Foundation, Inc., 59 Temple Place - Suite 330, Boston, % MA 02111-1307, USA. % -% This is version 0.1 Wed Aug 10 2005 +% This is version 0.41 Tue Sep 26 2006 Dec % % The module is documentet in exteps.pdf picture epspicture; +string extra_begineps; extra_begineps = ""; +string extra_endeps; extra_endeps = ""; +boolean extepsverbose; extepsverbose = true; %% String handling tool string string_split[]; @@ -48,7 +51,7 @@ def begineps text F = begingroup; save file; string file; file = F; save angle; numeric angle; angle = 0; - save clip; boolean clip; clip = false; + save clipping; boolean clipping; clipping = false; save scale; pair scale; scale = (1,1); save base; pair base; base = origin; save __bbxfound; boolean __bbxfound; __bbxfound = false; @@ -61,10 +64,17 @@ def begineps text F = save pct; numeric pct; save width; numeric width; save height; numeric height; + save clippath; path clippath; + save largefile; boolean largefile; largefile = false; + save gridllx; numeric gridllx; + save gridlly; numeric gridlly; + save gridurx; numeric gridurx; + save gridury; numeric gridury; %% Finding the bounding box forever: __eps__currentline := readfrom F; if substring(0,14) of __eps__currentline = "%%BoundingBox:": + exitif __eps__currentline = EOF; % PATCH D. Roegel 23-sep-2006 __bbxline := substring(14, infinity) of __eps__currentline; __bbxfound := true; splitstring __bbxline; @@ -75,27 +85,24 @@ def begineps text F = fi exitif __bbxfound; endfor + if not __bbxfound: + message "Warning: No bounding box found."; + message " Setting bounding box to 0 0 1 1"; + llx = lly = 0; + urx = ury = 1; + fi closefrom F; + scantokens extra_begineps; __base = -(llx,lly); pct = (urx - llx)/100; %% To ensure the right bounding box of the output file %% a picture with the same size as the eps figure is added. epspicture := nullpicture; - setbounds epspicture to ((0,0)--(0,ury-lly)--(urx-llx,ury-lly)--(urx-llx,0)--cycle); + clippath = (0,0)--(0,ury-lly)--(urx-llx,ury-lly)--(urx-llx,0)--cycle; + setbounds epspicture to clippath; enddef; def endeps = -%% Drawing the grid - if grid: - for i = 0 step gridstep*pct until (urx - llx): - epsdraw (i,0)--(i,ury - lly); - epslabel.bot(((decimal.(i/pct) & "%") infont defaultfont) rotated -90, (i,0)); - endfor - for i = 0 step gridstep*pct until (epsilon + ury - lly): - epsdraw (0,i)--(urx - llx,i); - epslabel.lft(((decimal.(i/pct) & "%") infont defaultfont), (0,i)); - endfor - fi %% Calculating scale if width and/or height is known if (known width) and (known height): scale := (width/(urx - llx),height/(ury - lly)); @@ -109,14 +116,10 @@ def endeps = if base <> origin: special decimal.xpart.base & " " & decimal.ypart.base & " translate"; fi - if scale <> (1,1): - special decimal xpart.scale & " " & decimal ypart.scale & " scale"; - fi if angle <> 0: special decimal angle & " rotate"; - epspicture := epspicture rotatedaround(origin)(angle); fi - if __base <> origin: + if __base <> origin: special decimal.xpart.__base & " " & decimal.ypart.__base & " translate"; fi if scale <> (1,1): @@ -124,30 +127,86 @@ def endeps = if xpart.scale <> ypart.scale: yscaled (ypart.scale/xpart.scale) fi; + special decimal xpart.scale & " " & decimal ypart.scale & " scale"; fi - if clip: - special "newpath "; - special decimal llx & " " & decimal lly & " moveto"; - special decimal llx & " " & decimal ury & " lineto"; - special decimal urx & " " & decimal ury & " lineto"; - special decimal urx & " " & decimal lly & " lineto"; - special decimal llx & " " & decimal lly & " lineto"; - special "closepath clip"; + if angle <> 0: + epspicture := epspicture rotatedaround(origin)(angle); fi - special "%%BeginDocument: " & file; - forever: - __eps__currentline := readfrom file; - exitunless __eps__currentline <> EOF; - special __eps__currentline; - endfor - special "%%EndDocument: " & file; - special "grestore"; - closefrom file; - if base <> (0,0): - epspicture := epspicture shifted base; +%% Drawing the grid !! After the scaling :-) + if unknown gridllx: + gridllx = 0; fi - addto currentpicture also epspicture; -endgroup; + if unknown gridlly: + gridlly = 0; + fi + if unknown gridurx: + gridurx = (urx - llx)/pct; + fi + if unknown gridury: + gridury = (ury - lly)/pct; + fi + if grid: + save __gridpicture; picture __gridpicture; __gridpicture := nullpicture; + for i = gridllx*pct step gridstep*pct until (epsilon + gridurx*pct): + addto __gridpicture doublepath (i*xpart.scale,gridlly*pct*ypart.scale)--(i*xpart.scale,gridury*pct*ypart.scale) withpen currentpen; + addto __gridpicture also thelabel.bot(((decimal.(i/pct) & "%") infont defaultfont) rotated -90, (i*xpart.scale,gridlly*pct*ypart.scale)); + endfor + for i = gridlly*pct step gridstep*pct until (epsilon + gridury*pct): + addto __gridpicture doublepath (gridllx*pct*xpart.scale,i*ypart.scale)--(gridurx*pct*xpart.scale,i*ypart.scale) withpen currentpen; + addto __gridpicture also thelabel.lft(((decimal.(i/pct) & "%") infont defaultfont), (gridllx*pct*xpart.scale,i*ypart.scale)); + endfor + if angle <> 0: + __gridpicture := __gridpicture rotatedaround(origin)(angle); + fi + addto epspicture also __gridpicture; + fi + if clipping: + save __clippath; path __clippath; + __clippath=clippath shifted (llx,lly); + special "newpath " & decimal.xpart.point 0 of __clippath + & " " & decimal.ypart.point 0 of __clippath & " moveto"; + for i = 0 upto length.__clippath-1: + special decimal.xpart.postcontrol i of __clippath & " " & + decimal.ypart.postcontrol i of __clippath & " " & + decimal.xpart.precontrol (i+1) of __clippath & " " & + decimal.ypart.precontrol (i+1) of __clippath & " " & + decimal.xpart.point (i+1) of __clippath & " " & + decimal.ypart.point (i+1) of __clippath & " curveto"; + endfor; + special "closepath clip"; + fi + special "save"; + special "userdict begin"; + special "/showpage {} def"; + special "%%BeginDocument: " & file; + if largefile: + special "%% MetaPost exteps large file->" & file; + if extepsverbose: + message "exteps notification: File " & file & " not inserted into " & jobname & "." & decimal.charcode; + message " Run 'delfin " & jobname & "." & decimal.charcode & "' to insert " & file; + message " This is caused by setting 'largefile:=true'"; + message ""; + fi + else: + if extepsverbose: + message "Inserting " & file & " into " & jobname & "." & decimal.charcode; + fi + forever: + __eps__currentline := readfrom file; + exitunless __eps__currentline <> EOF; + special __eps__currentline; + endfor + fi + special "%%EndDocument: " & file; + scantokens extra_endeps; + special "end restore"; + special "grestore"; + closefrom file; + if base <> (0,0): + epspicture := epspicture shifted base; + fi + addto currentpicture also epspicture; + endgroup; enddef; %% Special drawing commands |