 |
 |
QotD |
"To be or not to be" – Shakespeare
|
|
        |
 |
SVG construction example 1 with group
Last updated at 10:59 am UTC on 8 September 2018
The SVG construction example 1 using a SVG group element [1]. The enclosed elements inherit the color attribute.
circle := [:cx :cy :r | '<circle cx="', cx printString, '" cy="', cy printString, '" r="', r printString, '" />'].
Transcript clear.
Transcript show: '<html><svg>';cr.
Transcript show: '<g fill="red">';cr.
1 to: 5 do: [:i |
Transcript show: (circle value: (i*50) value: 50 value: 20); cr].
Transcript show: '</g>'; cr.
Transcript show: '</svg></html>';cr.
Result is
<html><svg>
<g fill="red">
<circle cx="50" cy="50" r="20" />
<circle cx="100" cy="50" r="20" />
<circle cx="150" cy="50" r="20" />
<circle cx="200" cy="50" r="20" />
<circle cx="250" cy="50" r="20" />
</g>
</svg></html>
[1] https://developer.mozilla.org/en-US/docs/Web/SVG/Element/g
The <g> SVG element is a container used to group other SVG elements.