Wiki source code of SVG Macro (Radeox)
Last modified by Vincent Massol on 2016/06/05 21:51
Show last authors
author | version | line-number | content |
---|---|---|---|
1 | Displays SVG content as PNG images. | ||
2 | |||
3 | {{info}} | ||
4 | There's a newer [[XWiki Syntax 2.0 SVG Macro>>Extension.SVG Macro]]. | ||
5 | {{/info}} | ||
6 | |||
7 | Note: Uses the internal SVG Plugin (bundled by default) to render the image. | ||
8 | |||
9 | == Usage == | ||
10 | |||
11 | {{code}} | ||
12 | {svg[:alternate text[|height[|width]]]} | ||
13 | svg content | ||
14 | {svg} | ||
15 | {{/code}} | ||
16 | |||
17 | == Parameters definition == | ||
18 | |||
19 | |=Name|=Optional|=Allowed values|=Default value|=Description | ||
20 | |text|true|any text| |The alternate text for the image, in case of a rendering error. | ||
21 | |height|true|a strictly positive integer number|400|The height of the generated image. | ||
22 | |width|true|a strictly positive integer number|400|The width of the generated image. | ||
23 | |||
24 | == Content == | ||
25 | |||
26 | The content must be a valid SVG image. It can be retrieved from an attachment using Velocity, as in: | ||
27 | |||
28 | {{code}} | ||
29 | {svg}${doc.getAttachment('image.svg').getContentAsString()}{svg} | ||
30 | {{/code}} | ||
31 | |||
32 | {{warning}} | ||
33 | Prior to XWiki Enterprise 2.0M1, if an xml prologue is used, it must begin exactly after the opening {svg} tag, without a newline, as otherwise the conversion will fail. | ||
34 | {{/warning}} | ||
35 | |||
36 | == Example == | ||
37 | |||
38 | {{code}} | ||
39 | {svg:The XWiki logo|100}<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" | ||
40 | viewBox="-57 -57 324 114" width="162" height="57" style="overflow: hidden"> | ||
41 | <style type="text/css"> | ||
42 | * { | ||
43 | fill: none; | ||
44 | stroke: #999; | ||
45 | stroke-width: 7.5px; | ||
46 | stroke-linecap: round; | ||
47 | stroke-linejoin: round; | ||
48 | } | ||
49 | .X { | ||
50 | stroke-width: 13px; | ||
51 | } | ||
52 | .wiki { | ||
53 | stroke-width: 3px; | ||
54 | } | ||
55 | </style> | ||
56 | <defs> | ||
57 | <g id="dash" transform="translate(20 -20)"> | ||
58 | <path d="M 3 -3 L 14 -14"/> | ||
59 | </g> | ||
60 | </defs> | ||
61 | <use xlink:href="#dash" transform="rotate(-45)" class="north"/> | ||
62 | <use xlink:href="#dash" transform="rotate(45)" class="east"/> | ||
63 | <use xlink:href="#dash" transform="rotate(135)" class="south"/> | ||
64 | <use xlink:href="#dash" transform="rotate(-135)" class="west"/> | ||
65 | <line class="X" x1="-35" y1="-40" x2="35" y2="40"/> | ||
66 | <line class="X" x1="-35" y1="40" x2="35" y2="-40"/> | ||
67 | <path class="wiki" transform="translate(59 -41.5) scale(3.19)" d="M 0 0 L 5 26 14 0 23 26 28 0 M 33.5 0 V 26 M 40 0 V 26 M 55 0 L 42 13 55 26 M 60.5 0 V 26"/> | ||
68 | </svg>{svg} | ||
69 | {{/code}} |