diff options
author | Hans Hagen <pragma@wxs.nl> | 2017-01-17 18:05:46 +0100 |
---|---|---|
committer | Context Git Mirror Bot <phg42.2a@gmail.com> | 2017-01-17 18:05:46 +0100 |
commit | 0cfeab235554eeee0dddd6c3f44d3939ab490ff1 (patch) | |
tree | fed70e9a3332741e5294a01197c716dff8556506 /metapost | |
parent | 72d161c0a522fd92f32edd3588fa126c453f4a3d (diff) | |
download | context-0cfeab235554eeee0dddd6c3f44d3939ab490ff1.tar.gz |
2017-01-17 17:43:00
Diffstat (limited to 'metapost')
-rw-r--r-- | metapost/context/base/mpii/mp-core.mpii | 2 | ||||
-rw-r--r-- | metapost/context/base/mpiv/mp-abck.mpiv | 35 | ||||
-rw-r--r-- | metapost/context/base/mpiv/mp-luas.mpiv | 16 | ||||
-rw-r--r-- | metapost/context/base/mpiv/mp-tool.mpiv | 45 |
4 files changed, 92 insertions, 6 deletions
diff --git a/metapost/context/base/mpii/mp-core.mpii b/metapost/context/base/mpii/mp-core.mpii index 33e9b386e..79b5d2ab7 100644 --- a/metapost/context/base/mpii/mp-core.mpii +++ b/metapost/context/base/mpii/mp-core.mpii @@ -897,7 +897,7 @@ enddef ; save_multipar (i,3,multipar) ; - elseif multi_column_first_page_hack and ((nxy[fpos]=RealPageNumber) and (nxy[tpos]>=RealPageNumber) : % and (NOfTextColumns>1)) : + elseif multi_column_first_page_hack and ((nxy[fpos]=RealPageNumber) and (nxy[tpos]>=RealPageNumber)) : % and (NOfTextColumns>1)) : save_multipar (i,2,multipar) ; diff --git a/metapost/context/base/mpiv/mp-abck.mpiv b/metapost/context/base/mpiv/mp-abck.mpiv index e0c5896e1..8b5f0a534 100644 --- a/metapost/context/base/mpiv/mp-abck.mpiv +++ b/metapost/context/base/mpiv/mp-abck.mpiv @@ -256,3 +256,38 @@ enddef ; def anchor_box (expr n,x,y,w,h,d) = currentpicture := currentpicture shifted (-x,-y) ; enddef ; + +def draw_free_region(expr width, height, depth, loffset, roffset, toffset, boffset) = + + begingroup ; save b, o, l ; path b, o, l[] ; save d ; + + b := fullsquare + xysized(width,height+depth) ; + o := b + topenlarged toffset + bottomenlarged boffset + leftenlarged loffset + rightenlarged roffset ; + d := max(PaperWidth,PaperHeight) ; + + fill o withcolor .5white ; + fill b withcolor .7white ; + + interim linecap := butt ; + + l[1] := topboundary (topboundary o leftenlarged d rightenlarged d) ; + l[2] := bottomboundary (bottomboundary o leftenlarged d rightenlarged d) ; + l[3] := leftboundary (leftboundary o topenlarged d bottomenlarged d) ; + l[4] := rightboundary (rightboundary o topenlarged d bottomenlarged d) ; + + for i=1 upto 4 : + draw l[i] withpen pencircle scaled 1bp withcolor white ; + draw l[i] withpen pencircle scaled 1bp dashed (evenly scaled 1bp) withcolor black ; + endfor ; + + setbounds currentpicture to b ; + + endgroup ; + +enddef ; + diff --git a/metapost/context/base/mpiv/mp-luas.mpiv b/metapost/context/base/mpiv/mp-luas.mpiv index 253438dee..7dd569321 100644 --- a/metapost/context/base/mpiv/mp-luas.mpiv +++ b/metapost/context/base/mpiv/mp-luas.mpiv @@ -121,3 +121,19 @@ enddef ; vardef dimensions suffix a = lua.mp.dimensions(str a) enddef ; + +% More access + +def getdimen(expr k) = lua.mp._get_dimen_(k) enddef ; +def getcount(expr k) = lua.mp._get_count_(k) enddef ; +def gettoks (expr k) = lua.mp._get_toks_ (k) enddef ; +def setdimen(expr k, v) = lua.mp._set_dimen_(k,v) enddef ; +def setcount(expr k, v) = lua.mp._set_count_(k,v) enddef ; +def settoks (expr k, v) = lua.mp._set_toks_ (k,v) enddef ; + +% vardef getdimen(expr k) = save getdimen ; lua.mp.getdimen(k) enddef ; +% vardef getcount(expr k) = save getcount ; lua.mp.getcount(k) enddef ; +% vardef gettoks (expr k) = save gettoks ; lua.mp.gettoks (k) enddef ; +% vardef setdimen(expr k,v) = save setdimen ; lua.mp.setdimen(k,v) enddef ; +% vardef setcount(expr k,v) = save setcount ; lua.mp.setcount(k,v) enddef ; +% vardef settoks (expr k,v) = save settoks ; lua.mp.settoks (k,v) enddef ; diff --git a/metapost/context/base/mpiv/mp-tool.mpiv b/metapost/context/base/mpiv/mp-tool.mpiv index c3775ad92..3a0b7b5d3 100644 --- a/metapost/context/base/mpiv/mp-tool.mpiv +++ b/metapost/context/base/mpiv/mp-tool.mpiv @@ -797,7 +797,7 @@ primarydef p xyscaled q = % secundarydef does not work out well endgroup enddef ; -%D Some personal code that might move to another module +%D Some personal code that might move to another module (todo: save). def set_grid(expr w, h, nx, ny) = boolean grid[][] ; boolean grid_full ; @@ -2439,8 +2439,22 @@ vardef mfun_straightened(expr sign, p) = _q_ enddef ; +% vardef mfun_straightened(expr sign, p) = +% save lp, lq, q ; path q ; q := p ; +% lp := length(p) ; +% forever : +% q := mfun_do_straightened(sign,q) ; +% lq := length(q) ; +% exitif lp = lq ; +% lp := lq ; +% endfor ; +% q +% enddef ; + +% can be optimized: + vardef mfun_do_straightened(expr sign, p) = - if length(p)>2 : % was 1, but straight lines are ok + if length(p) > 2 : % was 1, but straight lines are ok save pp ; path pp ; pp := point 0 of p ; for i=1 upto length(p)-1 : @@ -2450,10 +2464,10 @@ vardef mfun_do_straightened(expr sign, p) = endfor ; save n, ok ; numeric n ; boolean ok ; n := length(pp) ; ok := false ; - if n>2 : - for i=0 upto n : % evt hier ook round + if n > 2 : + for i=0 upto n : if unitvector(round(point i of pp - point if i=0 : n else : i-1 fi of pp)) <> - sign * unitvector(round(point if i=n : 0 else : i+1 fi of pp - point i of pp)) : + sign * unitvector(round(point if i=n : 0 else : i+1 fi of pp - point i of pp)) : if ok : -- else : @@ -3363,6 +3377,27 @@ primarydef p insideof q = endgroup enddef ; +% primarydef p insideof q = +% if (path q or picture q) : +% if (path p or picture p) : +% (xpart llcorner p > xpart llcorner q) and +% (xpart urcorner p < xpart urcorner q) and +% (ypart llcorner p > ypart llcorner q) and +% (ypart urcorner p < ypart urcorner q) +% elseif pair p : +% (xpart p > xpart llcorner q) and +% (xpart p < xpart urcorner q) and +% (ypart p > ypart llcorner q) and +% (ypart p < ypart urcorner q) +% fi +% elseif (numeric p and pair q) : +% % range check +% (p >= xpart q) and (p <= ypart q) +% else : % maybe triplets and such +% false +% fi +% enddef ; + primarydef p outsideof q = not (p insideof q) enddef ; |