summaryrefslogtreecommitdiff
path: root/doc/context/sources/general/manuals/luametafun/luametafun-svg.tex
blob: f7aba06fd3d7e4b938867d02eea3c4f5bc67e97e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
% language=us

\environment luametafun-style

\startcomponent luametafun-svg

\startchapter[title={SVG}]

There is not that much to tell about this command. It translates an \SVG\ image
to \METAPOST\ operators. We took a few images from a mozilla emoji font:

\startbuffer[2]
\startMPcode
    draw lmt_svg [
        filename = "mozilla-svg-002.svg",
        height   = 2cm,
        width    = 8cm,
    ] ;
\stopMPcode
\stopbuffer

\typebuffer[2][option=TEX]

\startlinecorrection
    \getbuffer[2]
\stoplinecorrection

Because we get pictures, you can do mess around with them:

\startbuffer[1]
\startMPcode
    picture p ; p := lmt_svg [ filename = "mozilla-svg-001.svg" ] ;
    numeric w ; w := bbwidth(p) ;
    draw p ;
    draw p xscaled -1 shifted (2.5*w,0);
    draw p rotatedaround(center p,45) shifted (3.0*w,0) ;
    draw image (
        for i within p : if filled i :
            draw pathpart i withcolor green ;
        fi endfor ;
    ) shifted (4.5*w,0);
    draw image (
        for i within p : if filled i :
            fill pathpart i withcolor red withtransparency (1,.25) ;
        fi endfor ;
    ) shifted (6*w,0);
\stopMPcode
\stopbuffer

\typebuffer[1][option=TEX]

\startlinecorrection
    \getbuffer[1]
\stoplinecorrection

Of course. often you won't know in advance what is inside the image and how (well)
it has been defined so the previous example is more about showing some \METAPOST\
muscle.

The supported parameters are:

\starttabulate[|T|T|T|p|]
\FL
\BC name     \BC type    \BC default \BC comment \NC \NR
\ML
\NC filename \NC path    \NC \NC \NC \NR
\NC width    \NC numeric \NC \NC \NC \NR
\NC height   \NC numeric \NC \NC \NC \NR
\LL
\stoptabulate

\stopchapter

\stopcomponent