diff options
author | Hans Hagen <pragma@wxs.nl> | 2012-01-05 19:27:39 +0100 |
---|---|---|
committer | Hans Hagen <pragma@wxs.nl> | 2012-01-05 19:27:39 +0100 |
commit | 598c44b5523a78a5bf481ad93c88e42dec995482 (patch) | |
tree | c04bf4c023cc0e5105e340ad1275732bcea4a53a /metapost | |
parent | 3ebffee90ab738221306b6642480dce1ad96cac4 (diff) | |
download | context-598c44b5523a78a5bf481ad93c88e42dec995482.tar.gz |
beta 2011.12.13 15:17
Diffstat (limited to 'metapost')
-rw-r--r-- | metapost/context/base/mp-shap.mpiv | 236 | ||||
-rw-r--r-- | metapost/context/base/mp-tool.mpiv | 11 |
2 files changed, 128 insertions, 119 deletions
diff --git a/metapost/context/base/mp-shap.mpiv b/metapost/context/base/mp-shap.mpiv index 291506997..c86edaf82 100644 --- a/metapost/context/base/mp-shap.mpiv +++ b/metapost/context/base/mp-shap.mpiv @@ -17,118 +17,130 @@ boolean context_shap ; context_shap := true ; path predefined_shapes[] ; -begingroup ; - -save xradius, yradius, xxradius, yyradius ; -save ll, lr, ur, ul, llx, lly, lrx, lry, urx, ury, ulx, uly, llxx, llyy, lrxx, lryy, urxx, uryy, ulxx, ulyy, lc, rc, tc, bc ; - -numeric xradius, yradius, xxradius, yyradius ; -pair ll, lr, ur, ul, llx, lly, lrx, lry, urx, ury, ulx, uly, llxx, llyy, lrxx, lryy, urxx, uryy, ulxx, ulyy, lc, rc, tc, bc ; - -xradius := .15 ; -yradius := .15 ; -xxradius := .10 ; -yyradius := .10 ; - -ll := llcorner (unitsquare shifted (-.5,-.5)) ; -lr := lrcorner (unitsquare shifted (-.5,-.5)) ; -ur := urcorner (unitsquare shifted (-.5,-.5)) ; -ul := ulcorner (unitsquare shifted (-.5,-.5)) ; - -llx := ll shifted (xradius,0) ; -lly := ll shifted (0,yradius) ; - -lrx := lr shifted (-xradius,0) ; -lry := lr shifted (0,yradius) ; - -urx := ur shifted (-xradius,0) ; -ury := ur shifted (0,-yradius) ; - -ulx := ul shifted (xradius,0) ; -uly := ul shifted (0,-yradius) ; - -llxx := ll shifted (xxradius,0) ; -llyy := ll shifted (0,yyradius) ; - -lrxx := lr shifted (-xxradius,0) ; -lryy := lr shifted (0,yyradius) ; - -urxx := ur shifted (-xxradius,0) ; -uryy := ur shifted (0,-yyradius) ; - -ulxx := ul shifted (xxradius,0) ; -ulyy := ul shifted (0,-yyradius) ; - -lc := ll shifted (0,.5) ; -rc := lr shifted (0,.5) ; -tc := ul shifted (.5,0) ; -bc := ll shifted (.5,0) ; - -predefined_shapes[ 0] := (origin--cycle) ; -predefined_shapes[ 5] := (llx--lrx{right}...rc...{left}urx--ulx{left}...lc...{right}cycle) ; -predefined_shapes[ 6] := (ll--lrx{right}...rc...{left}urx--ul--cycle) ; -predefined_shapes[ 7] := (ll--lrx{right}...rc...{left}urx--ul--cycle) rotatedaround(origin,180) ; -predefined_shapes[ 8] := (lr--ury{up}...tc...{down}uly--ll--cycle) ; -predefined_shapes[ 9] := (lr--ury{up}...tc...{down}uly--ll--cycle) rotatedaround(origin,180) ; -predefined_shapes[10] := (ll--lr--ur--ul--ll--ur--ul--ll--cycle) ; -predefined_shapes[11] := (ll--lr--ur--ul--ll--lr--ul--ll--cycle) ; -predefined_shapes[12] := (ll--lrx--ur--ulx--cycle) ; -predefined_shapes[13] := (llx--lr--urx--ul--cycle) ; -predefined_shapes[14] := (lly--bc--lry--ury--tc--uly--cycle) ; -predefined_shapes[15] := (llx--lrx--rc--urx--ulx--lc--cycle) ; -predefined_shapes[16] := (ll--lrx--rc--urx--ul--cycle) ; -predefined_shapes[17] := (ll--lrx--rc--urx--ul--cycle) rotatedaround(origin,180) ; -predefined_shapes[18] := (lr--ury--tc--uly--ll--cycle) ; -predefined_shapes[19] := (lr--ury--tc--uly--ll--cycle) rotatedaround(origin,180) ; -predefined_shapes[20] := (ll--lr--ur--ul--ll--llxx--ulxx--ul--ll--lr--ur--urxx--lrxx--cycle) ; -predefined_shapes[21] := (ul--ll--lr--ur--ul--ulyy--uryy--ur--ul--ll--lr--lryy--llyy--cycle) ; -predefined_shapes[22] := (ll--lrx--lry--ur--ulx--uly--cycle) ; -predefined_shapes[23] := (llx--lr--ury--urx--ul--lly--cycle) ; -predefined_shapes[24] := (ll--lr--ur--ul--cycle) ; -predefined_shapes[25] := (llx--lrx--lry--ury--urx--ulx--uly--lly--cycle) ; -predefined_shapes[26] := (ll--lrx--lry--ur--ul--cycle) ; -predefined_shapes[27] := (ll--lr--ury--urx--ul--cycle) rotatedaround(origin,180) ; -predefined_shapes[28] := (ll--lr--ury--urx--ul--cycle) ; -predefined_shapes[29] := (ll--lrx--lry--ur--ul--cycle) rotatedaround(origin,180) ; -predefined_shapes[30] := (bc{right}...{up}rc...tc{left}...{down}lc...{right}bc & bc--tc & tc{left}..{down}lc & lc--rc & rc{up}..tc{left}...{down}lc...{right}bc & cycle) rotated 45; -predefined_shapes[31] := (bc{right}...{up}rc...tc{left}...{down}lc...{right}bc & bc--tc & tc{left}..{down}lc & lc--rc & rc{up}..tc{left}...{down}lc...{right}bc & cycle) ; -predefined_shapes[32] := (ll{right}...{right}lry--ur--ul--ll--cycle) ; -predefined_shapes[33] := (ll{right}...{right}lry--ur--ul--ll--cycle--ul--ulx--ulx shifted(0,yyradius)--ur shifted(yyradius,yyradius)--lry shifted(yyradius,yyradius)--lry shifted(0,yyradius)--ur--ul--cycle ) ; -predefined_shapes[34] := (uly..tc..ury & ury..tc shifted (0,-2yradius)..uly & uly--lly & lly..bc..lry & lry--ury & ury..tc shifted (0,-2yradius)..uly & cycle ) ; -predefined_shapes[35] := (bc{right}...rc{up}...tc{left}...lc{down}...cycle) ; -predefined_shapes[36] := (ul--tc{right}..rc{down}..{left}bc--ll & ll..(xpart llx, ypart lc)..ul & cycle) ; -predefined_shapes[37] := (ul--tc{right}..rc{down}..{left}bc--ll & ll..(xpart llx, ypart lc)..ul & cycle) rotatedaround(origin,180) ; -predefined_shapes[38] := (ll--lc{up}..tc{right}..{down}rc--lr & lr..(xpart bc, ypart lly)..ll & cycle) ; -predefined_shapes[39] := (ll--lc{up}..tc{right}..{down}rc--lr & lr..(xpart bc, ypart lly)..ll & cycle) rotatedaround(origin,180) ; -predefined_shapes[40] := (ll--lr--ur--ul--ll--ur--ul--ll--lr--ul--ll--cycle) ; -predefined_shapes[41] := (ll--lr--ur--ul--ll--lr--rc--lc--ll--bc--tc--ul--ll & cycle) ; -predefined_shapes[42] := (ll--lr--origin shifted (+epsilon,0)--ur--ul--origin shifted (-epsilon,0)--cycle) ; -predefined_shapes[43] := (ll--ul--origin shifted (0,+epsilon)--ur--lr--origin shifted (0,-epsilon)--cycle) ; -predefined_shapes[45] := (bc--rc--tc--lc--cycle) ; -predefined_shapes[46] := (ll--ul--rc--cycle) ; -predefined_shapes[47] := (ll--ul--rc--cycle) rotatedaround(origin,180) ; -predefined_shapes[48] := (ul--ur--bc--cycle) rotatedaround(origin,180) ; -predefined_shapes[49] := (ul--ur--bc--cycle) ; -predefined_shapes[56] := (ll--lry--ury--ul--cycle) ; -predefined_shapes[57] := (ll--lry--ury--ul--cycle) rotatedaround(origin,180) ; -predefined_shapes[58] := (ll--ulx--urx--lr--cycle) ; -predefined_shapes[59] := (ll--ulx--urx--lr--cycle) rotatedaround(origin,180); -predefined_shapes[66] := (rc--origin shifted ( epsilon,0) --cycle & rc--origin--cycle ) ; -predefined_shapes[67] := (lc--origin shifted (-epsilon,0) --cycle & lc--origin--cycle ) ; -predefined_shapes[68] := (tc--origin shifted (0, epsilon) --cycle & tc--origin--cycle ) ; -predefined_shapes[69] := (bc--origin shifted (0,-epsilon) --cycle & bc--origin--cycle ) ; -predefined_shapes[75] := (lly--lry--ury--uly--cycle) rotatedaround(origin,180) ; -predefined_shapes[76] := (ll--lr--ur--uly--cycle) rotatedaround(origin,180) ; -predefined_shapes[77] := (ll--lr--ury--ul--cycle) rotatedaround(origin,180) ; -predefined_shapes[78] := (lly--lr--ur--ul--cycle) rotatedaround(origin,180) ; -predefined_shapes[79] := (ll--lry--ur--ul--cycle) rotatedaround(origin,180) ; - -numeric predefined_shapes_xradius ; predefined_shapes_xradius := xradius ; -numeric predefined_shapes_yradius ; predefined_shapes_yradius := yradius ; -numeric predefined_shapes_xxradius ; predefined_shapes_xxradius := xxradius ; -numeric predefined_shapes_yyradius ; predefined_shapes_yyradius := yyradius ; - -endgroup ; +def start_predefined_shape_definition = + + begingroup ; + + save xradius, yradius, xxradius, yyradius ; + save ll, lr, ur, ul, llx, lly, lrx, lry, urx, ury, ulx, uly, llxx, llyy, lrxx, lryy, urxx, uryy, ulxx, ulyy, lc, rc, tc, bc ; + + numeric xradius, yradius, xxradius, yyradius ; + pair ll, lr, ur, ul, llx, lly, lrx, lry, urx, ury, ulx, uly, llxx, llyy, lrxx, lryy, urxx, uryy, ulxx, ulyy, lc, rc, tc, bc ; + + xradius := .15 ; + yradius := .15 ; + xxradius := .10 ; + yyradius := .10 ; + + ll := llcorner (unitsquare shifted (-.5,-.5)) ; + lr := lrcorner (unitsquare shifted (-.5,-.5)) ; + ur := urcorner (unitsquare shifted (-.5,-.5)) ; + ul := ulcorner (unitsquare shifted (-.5,-.5)) ; + + llx := ll shifted (xradius,0) ; + lly := ll shifted (0,yradius) ; + + lrx := lr shifted (-xradius,0) ; + lry := lr shifted (0,yradius) ; + + urx := ur shifted (-xradius,0) ; + ury := ur shifted (0,-yradius) ; + + ulx := ul shifted (xradius,0) ; + uly := ul shifted (0,-yradius) ; + + llxx := ll shifted (xxradius,0) ; + llyy := ll shifted (0,yyradius) ; + + lrxx := lr shifted (-xxradius,0) ; + lryy := lr shifted (0,yyradius) ; + + urxx := ur shifted (-xxradius,0) ; + uryy := ur shifted (0,-yyradius) ; + + ulxx := ul shifted (xxradius,0) ; + ulyy := ul shifted (0,-yyradius) ; + + lc := ll shifted (0,.5) ; + rc := lr shifted (0,.5) ; + tc := ul shifted (.5,0) ; + bc := ll shifted (.5,0) ; + +enddef ; + +def stop_predefined_shape_definition = + + endgroup ; + +enddef ; + +start_predefined_shape_definition ; + + predefined_shapes[ 0] := (origin--cycle) ; + predefined_shapes[ 5] := (llx--lrx{right}...rc...{left}urx--ulx{left}...lc...{right}cycle) ; + predefined_shapes[ 6] := (ll--lrx{right}...rc...{left}urx--ul--cycle) ; + predefined_shapes[ 7] := (ll--lrx{right}...rc...{left}urx--ul--cycle) rotatedaround(origin,180) ; + predefined_shapes[ 8] := (lr--ury{up}...tc...{down}uly--ll--cycle) ; + predefined_shapes[ 9] := (lr--ury{up}...tc...{down}uly--ll--cycle) rotatedaround(origin,180) ; + predefined_shapes[10] := (ll--lr--ur--ul--ll--ur--ul--ll--cycle) ; + predefined_shapes[11] := (ll--lr--ur--ul--ll--lr--ul--ll--cycle) ; + predefined_shapes[12] := (ll--lrx--ur--ulx--cycle) ; + predefined_shapes[13] := (llx--lr--urx--ul--cycle) ; + predefined_shapes[14] := (lly--bc--lry--ury--tc--uly--cycle) ; + predefined_shapes[15] := (llx--lrx--rc--urx--ulx--lc--cycle) ; + predefined_shapes[16] := (ll--lrx--rc--urx--ul--cycle) ; + predefined_shapes[17] := (ll--lrx--rc--urx--ul--cycle) rotatedaround(origin,180) ; + predefined_shapes[18] := (lr--ury--tc--uly--ll--cycle) ; + predefined_shapes[19] := (lr--ury--tc--uly--ll--cycle) rotatedaround(origin,180) ; + predefined_shapes[20] := (ll--lr--ur--ul--ll--llxx--ulxx--ul--ll--lr--ur--urxx--lrxx--cycle) ; + predefined_shapes[21] := (ul--ll--lr--ur--ul--ulyy--uryy--ur--ul--ll--lr--lryy--llyy--cycle) ; + predefined_shapes[22] := (ll--lrx--lry--ur--ulx--uly--cycle) ; + predefined_shapes[23] := (llx--lr--ury--urx--ul--lly--cycle) ; + predefined_shapes[24] := (ll--lr--ur--ul--cycle) ; + predefined_shapes[25] := (llx--lrx--lry--ury--urx--ulx--uly--lly--cycle) ; + predefined_shapes[26] := (ll--lrx--lry--ur--ul--cycle) ; + predefined_shapes[27] := (ll--lr--ury--urx--ul--cycle) rotatedaround(origin,180) ; + predefined_shapes[28] := (ll--lr--ury--urx--ul--cycle) ; + predefined_shapes[29] := (ll--lrx--lry--ur--ul--cycle) rotatedaround(origin,180) ; + predefined_shapes[30] := (bc{right}...{up}rc...tc{left}...{down}lc...{right}bc & bc--tc & tc{left}..{down}lc & lc--rc & rc{up}..tc{left}...{down}lc...{right}bc & cycle) rotated 45; + predefined_shapes[31] := (bc{right}...{up}rc...tc{left}...{down}lc...{right}bc & bc--tc & tc{left}..{down}lc & lc--rc & rc{up}..tc{left}...{down}lc...{right}bc & cycle) ; + predefined_shapes[32] := (ll{right}...{right}lry--ur--ul--ll--cycle) ; + predefined_shapes[33] := (ll{right}...{right}lry--ur--ul--ll--cycle--ul--ulx--ulx shifted(0,yyradius)--ur shifted(yyradius,yyradius)--lry shifted(yyradius,yyradius)--lry shifted(0,yyradius)--ur--ul--cycle ) ; + predefined_shapes[34] := (uly..tc..ury & ury..tc shifted (0,-2yradius)..uly & uly--lly & lly..bc..lry & lry--ury & ury..tc shifted (0,-2yradius)..uly & cycle ) ; + predefined_shapes[35] := (bc{right}...rc{up}...tc{left}...lc{down}...cycle) ; + predefined_shapes[36] := (ul--tc{right}..rc{down}..{left}bc--ll & ll..(xpart llx, ypart lc)..ul & cycle) ; + predefined_shapes[37] := (ul--tc{right}..rc{down}..{left}bc--ll & ll..(xpart llx, ypart lc)..ul & cycle) rotatedaround(origin,180) ; + predefined_shapes[38] := (ll--lc{up}..tc{right}..{down}rc--lr & lr..(xpart bc, ypart lly)..ll & cycle) ; + predefined_shapes[39] := (ll--lc{up}..tc{right}..{down}rc--lr & lr..(xpart bc, ypart lly)..ll & cycle) rotatedaround(origin,180) ; + predefined_shapes[40] := (ll--lr--ur--ul--ll--ur--ul--ll--lr--ul--ll--cycle) ; + predefined_shapes[41] := (ll--lr--ur--ul--ll--lr--rc--lc--ll--bc--tc--ul--ll & cycle) ; + predefined_shapes[42] := (ll--lr--origin shifted (+epsilon,0)--ur--ul--origin shifted (-epsilon,0)--cycle) ; + predefined_shapes[43] := (ll--ul--origin shifted (0,+epsilon)--ur--lr--origin shifted (0,-epsilon)--cycle) ; + predefined_shapes[45] := (bc--rc--tc--lc--cycle) ; + predefined_shapes[46] := (ll--ul--rc--cycle) ; + predefined_shapes[47] := (ll--ul--rc--cycle) rotatedaround(origin,180) ; + predefined_shapes[48] := (ul--ur--bc--cycle) rotatedaround(origin,180) ; + predefined_shapes[49] := (ul--ur--bc--cycle) ; + predefined_shapes[56] := (ll--lry--ury--ul--cycle) ; + predefined_shapes[57] := (ll--lry--ury--ul--cycle) rotatedaround(origin,180) ; + predefined_shapes[58] := (ll--ulx--urx--lr--cycle) ; + predefined_shapes[59] := (ll--ulx--urx--lr--cycle) rotatedaround(origin,180); + predefined_shapes[66] := (rc--origin shifted ( epsilon,0) --cycle & rc--origin--cycle ) ; + predefined_shapes[67] := (lc--origin shifted (-epsilon,0) --cycle & lc--origin--cycle ) ; + predefined_shapes[68] := (tc--origin shifted (0, epsilon) --cycle & tc--origin--cycle ) ; + predefined_shapes[69] := (bc--origin shifted (0,-epsilon) --cycle & bc--origin--cycle ) ; + predefined_shapes[75] := (lly--lry--ury--uly--cycle) rotatedaround(origin,180) ; + predefined_shapes[76] := (ll--lr--ur--uly--cycle) rotatedaround(origin,180) ; + predefined_shapes[77] := (ll--lr--ury--ul--cycle) rotatedaround(origin,180) ; + predefined_shapes[78] := (lly--lr--ur--ul--cycle) rotatedaround(origin,180) ; + predefined_shapes[79] := (ll--lry--ur--ul--cycle) rotatedaround(origin,180) ; + + numeric predefined_shapes_xradius ; predefined_shapes_xradius := xradius ; + numeric predefined_shapes_yradius ; predefined_shapes_yradius := yradius ; + numeric predefined_shapes_xxradius ; predefined_shapes_xxradius := xxradius ; + numeric predefined_shapes_yyradius ; predefined_shapes_yyradius := yyradius ; + +stop_predefined_shape_definition ; vardef some_shape_path (expr type) = if known predefined_shapes[type] : predefined_shapes[type] else : predefined_shapes[0] fi diff --git a/metapost/context/base/mp-tool.mpiv b/metapost/context/base/mp-tool.mpiv index 006e16e82..33c5b7d9a 100644 --- a/metapost/context/base/mp-tool.mpiv +++ b/metapost/context/base/mp-tool.mpiv @@ -2057,25 +2057,22 @@ enddef ; def showgrid (expr MinX, MaxX, DeltaX, MinY, MaxY, DeltaY) = % will move begingroup - save defaultfont, defaultscale, size ; - string defaultfont ; defaultfont := "cmtt10"; % i.e. infofont - numeric defaultscale ; defaultscale := 8pt / fontsize defaultfont; - numeric size ; size := 2pt ; + save size ; numeric size ; size := 2pt ; for x=MinX upto MaxX : for y=MinY upto MaxY : draw (x*DeltaX, y*DeltaY) withpen pencircle scaled if (x mod 5 = 0) and (y mod 5 = 0) : 1.5size withcolor .50white else : - size withcolor .75white + size withcolor .75white fi ; endfor ; endfor ; for x=MinX upto MaxX: - label.bot(decimal x, (x*DeltaX,-size)) ; + label.bot(textext("\infofont " & decimal x), (x*DeltaX,-size)) ; endfor ; for y=MinY upto MaxY: - label.lft(decimal y, (-size,y*DeltaY)) ; + label.lft(textext("\infofont " & decimal y), (-size,y*DeltaY)) ; endfor ; endgroup enddef; |