diff options
author | Hans Hagen <pragma@wxs.nl> | 2011-08-18 16:00:00 +0200 |
---|---|---|
committer | Hans Hagen <pragma@wxs.nl> | 2011-08-18 16:00:00 +0200 |
commit | 4e9248d3c8103ea8758c6173f7e3af603e0da642 (patch) | |
tree | 1f7f551567c93e3a62accc4c0d7e68a8169ab99f /metapost | |
parent | e7b67a4f409457e80dde3a5383071869ace85685 (diff) | |
download | context-4e9248d3c8103ea8758c6173f7e3af603e0da642.tar.gz |
beta 2011.08.18 16:00
Diffstat (limited to 'metapost')
-rw-r--r-- | metapost/context/base/mp-page.mp | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/metapost/context/base/mp-page.mp b/metapost/context/base/mp-page.mp index a4f0a86ef..0c2f41f03 100644 --- a/metapost/context/base/mp-page.mp +++ b/metapost/context/base/mp-page.mp @@ -477,17 +477,21 @@ enddef ; % Crop stuff -vardef crop_marks_lines (expr box, length, offset) = - save p ; picture p ; +vardef crop_marks_lines (expr box, length, offset, nx, ny) = + save p ; picture p ; save w, h, x, y ; numeric w, h, x, y ; p := image ( - draw ((llcorner box) -- (llcorner box) shifted (-length,0)) shifted (-offset,0) ; - draw ((llcorner box) -- (llcorner box) shifted (0,-length)) shifted (0,-offset) ; - draw ((lrcorner box) -- (lrcorner box) shifted ( length,0)) shifted ( offset,0) ; - draw ((lrcorner box) -- (lrcorner box) shifted (0,-length)) shifted (0,-offset) ; - draw ((ulcorner box) -- (ulcorner box) shifted (-length,0)) shifted (-offset,0) ; - draw ((ulcorner box) -- (ulcorner box) shifted (0, length)) shifted (0, offset) ; - draw ((urcorner box) -- (urcorner box) shifted ( length,0)) shifted ( offset,0) ; - draw ((urcorner box) -- (urcorner box) shifted (0, length)) shifted (0, offset) ; + x := if nx = 0 : 1 else : nx - 1 fi ; + y := if ny = 0 : 1 else : ny - 1 fi ; + w := bbwidth (box) / x ; + h := bbheight(box) / y ; + for i=0 upto y : + draw ((llcorner box) -- (llcorner box) shifted (-length,0)) shifted (-offset,i*h) ; + draw ((lrcorner box) -- (lrcorner box) shifted ( length,0)) shifted ( offset,i*h) ; + endfor ; + for i=0 upto x : + draw ((llcorner box) -- (llcorner box) shifted (0,-length)) shifted (i*w,-offset) ; + draw ((ulcorner box) -- (ulcorner box) shifted (0, length)) shifted (i*w, offset) ; + endfor ; ) ; setbounds p to box ; p @@ -627,12 +631,12 @@ def page_marks_add_marking(expr width, height, length, offset) = % todo: namespa enddef ; -def page_marks_add_lines(expr width, height, length, offset) = % todo: namespace +def page_marks_add_lines(expr width, height, length, offset, nx, ny) = % todo: namespace path page ; page := fullsquare xscaled width yscaled height ; path more ; more := page enlarged (offset+length/2,offset+length/2) ; - draw crop_marks_lines(page,length,offset) ; + draw crop_marks_lines(page,length,offset,nx,ny) ; setbounds currentpicture to page ; |