luametafun-svg.tex /size: 1750 b    last modification: 2021-10-28 13:50
1% language=us runpath=texruns:manuals/luametafun
2
3\environment luametafun-style
4
5\startcomponent luametafun-svg
6
7\startchapter[title={SVG}]
8
9There is not that much to tell about this command. It translates an \SVG\ image
10to \METAPOST\ operators. We took a few images from a mozilla emoji font:
11
12\startbuffer[2]
13\startMPcode
14    draw lmt_svg [
15        filename = "mozilla-svg-002.svg",
16        height   = 2cm,
17        width    = 8cm,
18    ] ;
19\stopMPcode
20\stopbuffer
21
22\typebuffer[2][option=TEX]
23
24\startlinecorrection
25    \getbuffer[2]
26\stoplinecorrection
27
28Because we get pictures, you can mess around with them:
29
30\startbuffer[1]
31\startMPcode
32    picture p ; p := lmt_svg [ filename = "mozilla-svg-001.svg" ] ;
33    numeric w ; w := bbwidth(p) ;
34    draw p ;
35    draw p xscaled -1 shifted (2.5*w,0);
36    draw p rotatedaround(center p,45) shifted (3.0*w,0) ;
37    draw image (
38        for i within p : if filled i :
39            draw pathpart i withcolor green ;
40        fi endfor ;
41    ) shifted (4.5*w,0);
42    draw image (
43        for i within p : if filled i :
44            fill pathpart i withcolor red withtransparency (1,.25) ;
45        fi endfor ;
46    ) shifted (6*w,0);
47\stopMPcode
48\stopbuffer
49
50\typebuffer[1][option=TEX]
51
52\startlinecorrection
53    \getbuffer[1]
54\stoplinecorrection
55
56Of course. often you won't know in advance what is inside the image and how (well)
57it has been defined so the previous example is more about showing some \METAPOST\
58muscle.
59
60The supported parameters are:
61
62\starttabulate[|T|T|T|p|]
63\FL
64\BC name     \BC type    \BC default \BC comment \NC \NR
65\ML
66\NC filename \NC path    \NC \NC \NC \NR
67\NC width    \NC numeric \NC \NC \NC \NR
68\NC height   \NC numeric \NC \NC \NC \NR
69\LL
70\stoptabulate
71
72\stopchapter
73
74\stopcomponent
75
76