MetaFun - Pragma ADE
MetaFun - Pragma ADE MetaFun - Pragma ADE
90 sample (z1 {curl 0} .. z2 .. {curl 0} z3, .625red) ; sample (z1 {curl infinity} .. z2 .. {curl infinity} z3, .625yellow) ; sample (z1 {curl 1} .. z2 .. {curl 1} z3, .625white) ; It may sound strange, but internally METAPOST can handle larger values than infinity. sample (z1 {curl infinity} .. z2 .. {curl infinity} z3, .625red) ; sample (z1 {curl 4infinity} .. z2 .. {curl 4infinity} z3, .625yellow) ; sample (z1 {curl 8infinity} .. z2 .. {curl 8infinity} z3, .625white) ; Although this is quite certainly undefined behaviour, interesting effects can be achieved. When you turn off METAPOST's first stage overflow catcher by setting warningcheck to zero, you can go upto 8 times infinity, which, being some 2 15 , is still far from what today's infinity is supposed to be. As the built--in METAPOST command .. accepts the curl and tension directives as described in this section, you will now probably understand the following plain METAPOST definitions: def -- = {curl 1} .. {curl 1} enddef ; def --- = .. tension infinity .. enddef ; def ... = .. tension atleast 1 .. enddef ; These definitions also point out why you cannot add directives to the left or right side of --, --and ...: they are directives themselves! 2.7 Transformations A transform is a vector that is used in what is called an affine transformation. To quote the META POST manual: “If p = (px,py) is a pair and T is a transform, then p transform T is a pair of the form: (tx + txxpx + txypy,ty + tyxpx + tyypy) where the six numeric quantities (tx,ty,txx,txy,tyx,tyy) determine T.” A few more details Transformations
7 In literature concerning POSTSCRIPT and PDF you will find many references to such transformation matrices. A matrix of (sx,0,0,sy,0,0) is scaling by sx in the horizontal direction and sy in the vertical direction, while (1,0,tx,1,0,ty) is a shift over tx,ty. Of course combinations are also possible. Although these descriptions seem in conflict with each other in the nature and order of the transform components in the vectors, the concepts are the same. You normally populate transformation matrices using scaled, shifted, rotated. transform t ; t := identity shifted (a,b) rotated c scaled d ; path p ; p := fullcircle transformed t ; The previous lines of code are equivalent to: path p ; p := fullcircle shifted (a,b) rotated c scaled d ; You always need a starting point, in this case the identity matrix identity: (0,0,1,0,0,1). By the way, in POSTSCRIPT the zero vector is (1,0,0,1,0,0). So, unless you want to extract the components using xpart, xypart, xxpart, ypart, yxpart and/or yypart, you may as well forget about the internal representation. You can invert a transformation using the inverse macro, which is defined as follows, using an equation: vardef inverse primary T = transform T_ ; T_ transformed T = identity ; T_ enddef ; Using transform matrices makes sense when similar transformations need to be applied on many paths, pictures, pens, or other transforms. However, in most cases you will use the predefined commands scaled, shifted, rotated and alike. We will now demonstrate the most common transformations in a text example. draw btex \bfd MetaFun etex ; draw boundingbox currentpicture withcolor .625yellow ; Before a METAPOST run, the btex ... etex's are filtered from the file and passed on to TEX. After that, the DVI file is converted to a list of pictures, which is consulted by METAPOST. 7 We can manipulate these pictures like any graphic as well as draw it with draw. MetaFun We show the transformations in relation to the origin and make the origin stand out a bit more by painting it a bit larger in white first. draw origin withpen pencircle scaled 1.5mm withcolor white ; draw origin withpen pencircle scaled 1mm withcolor .625red The origin is in the lower left corner of the picture. This is no longer the case in LUATEX where we use MPLIB. Transformations A few more details 91
- Page 43 and 44: linejoin=mitered linecap=butt linej
- Page 45 and 46: 1.15 Text Most dashpatterns can be
- Page 47 and 48: Z13 Z24 Z14 Z1 Z12 Z2 Z21 Z23 Z11 Z
- Page 49 and 50: 3 Because we want to call this macr
- Page 51 and 52: dotlabel.rt ("$Z_{3}$", z3) ; dotla
- Page 53 and 54: A different approach is to use a tw
- Page 55 and 56: The graphic extends beyond the boun
- Page 57 and 58: p := (p shifted (5cm,0)) randomized
- Page 59 and 60: path p ; p := (0,0) -- (2cm,3cm) ;
- Page 61 and 62: path p ; p := (0cm,0cm) -- (4cm,1cm
- Page 63 and 64: Here, the image macro creates an (a
- Page 65 and 66: So, in addition to on to specify a
- Page 67 and 68: Watch how we can pass a point (poin
- Page 69 and 70: 2 A few more details In this chapte
- Page 71 and 72: The second line does just as it say
- Page 73 and 74: fill shape ; draw shape ; filldraw
- Page 75 and 76: 2.3 Units 6 As you can see here, as
- Page 77 and 78: 2.4 Scaling and shifting When we dr
- Page 79 and 80: Especially when a path results from
- Page 81 and 82: points first order curve second ord
- Page 83 and 84: first iteration second iteration th
- Page 85 and 86: and get: We don't even need that mu
- Page 87 and 88: Figure 2.3 Circles with minimized i
- Page 89 and 90: The tension specifier can be used t
- Page 91 and 92: The asymetrical tensions are less p
- Page 93: z0 .. z1 .. z2 z0 {curl 1} .. z1 ..
- Page 97 and 98: currentpicture := currentpicture sl
- Page 99 and 100: We can achieve this by defining poi
- Page 101 and 102: We're still not there. Like in a pr
- Page 103 and 104: Due to the thicker line width used
- Page 105 and 106: left up down right The previous def
- Page 107 and 108: Here the & glues strings together,
- Page 109 and 110: picture p ; p := "MetaFun" normalin
- Page 111 and 112: pickup pencircle scaled 2pt ; draw
- Page 113 and 114: Because the z--variables are used f
- Page 115 and 116: 3 Embedded graphics In addition to
- Page 117 and 118: \startMPcode fill fullcircle scaled
- Page 119 and 120: \startuniqueMPgraphic{right or wron
- Page 121 and 122: {\externalfigure[mprun:extrafun::my
- Page 123 and 124: \startlinecorrection[blank] \proces
- Page 125 and 126: In order to prevent problems, we ad
- Page 127 and 128: There are a few more low level swit
- Page 129 and 130: When we convert color to gray, we u
- Page 131 and 132: 4 Enhancing the layout One of the m
- Page 133 and 134: 4.2 Overlay variables [offset=3pt,f
- Page 135 and 136: This background demonstrates that a
- Page 137 and 138: As you may know, TEX's ambassador i
- Page 139 and 140: This works as expected: \RotatedTex
- Page 141 and 142: We will now apply this knowledge of
- Page 143 and 144: p := p shifted (2o,OverlayHeight-yp
90<br />
sample (z1 {curl 0} .. z2 .. {curl 0} z3, .625red) ;<br />
sample (z1 {curl infinity} .. z2 .. {curl infinity} z3, .625yellow) ;<br />
sample (z1 {curl 1} .. z2 .. {curl 1} z3, .625white) ;<br />
It may sound strange, but internally METAPOST can handle larger values than infinity.<br />
sample (z1 {curl infinity} .. z2 .. {curl infinity} z3, .625red) ;<br />
sample (z1 {curl 4infinity} .. z2 .. {curl 4infinity} z3, .625yellow) ;<br />
sample (z1 {curl 8infinity} .. z2 .. {curl 8infinity} z3, .625white) ;<br />
Although this is quite certainly undefined behaviour, interesting effects can be achieved. When<br />
you turn off METAPOST's first stage overflow catcher by setting warningcheck to zero, you can go<br />
upto 8 times infinity, which, being some 2 15 , is still far from what today's infinity is supposed to<br />
be.<br />
As the built--in METAPOST command .. accepts the curl and tension directives as described in<br />
this section, you will now probably understand the following plain METAPOST definitions:<br />
def -- = {curl 1} .. {curl 1} enddef ;<br />
def --- = .. tension infinity .. enddef ;<br />
def ... = .. tension atleast 1 .. enddef ;<br />
These definitions also point out why you cannot add directives to the left or right side of --, --and<br />
...: they are directives themselves!<br />
2.7 Transformations<br />
A transform is a vector that is used in what is called an affine transformation. To quote the META<br />
POST manual:<br />
“If p = (px,py) is a pair and T is a transform, then p transform T is a pair of the form:<br />
(tx + txxpx + txypy,ty + tyxpx + tyypy)<br />
where the six numeric quantities (tx,ty,txx,txy,tyx,tyy) determine T.”<br />
A few more details Transformations