Last active
August 29, 2015 14:16
-
-
Save hhzl/a0685140950332726ed3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| svg circle | | |
svg := document createElementNS: 'http://www.w3.org/2000/svg' tag: 'svg'. | |
svg setAttribute: 'style' value: 'border: 1px solid black'. | |
svg setAttribute: 'width' value: '80'. | |
svg setAttribute: 'height' value: '200'. | |
svg setAttributeNS: 'http://www.w3.org/2000/xmlns/' | |
arg2: 'xmlns:xlink' arg3: 'http://www.w3.org/1999/xlink'. | |
circle := document createElementNS: 'http://www.w3.org/2000/svg' tag: 'circle'. | |
circle setAttribute: 'cx' value: '40'. | |
circle setAttribute: 'cy' value: '40'. | |
circle setAttribute: 'r' value: '24'. | |
circle setAttribute: 'style' value: 'stroke:#006600; fill:#00cc00'. | |
svg appendChild: circle. | |
circle := document createElementNS: 'http://www.w3.org/2000/svg' tag: 'circle'. | |
circle setAttribute: 'cx' value: '40'. | |
circle setAttribute: 'cy' value: '100'. | |
circle setAttribute: 'r' value: '24'. | |
circle setAttribute: 'style' value: 'stroke:#006600; fill: yellow'. | |
svg appendChild: circle. | |
circle := document createElementNS: 'http://www.w3.org/2000/svg' tag: 'circle'. | |
circle setAttribute: 'cx' value: '40'. | |
circle setAttribute: 'cy' value: '160'. | |
circle setAttribute: 'r' value: '24'. | |
circle setAttribute: 'style' value: 'stroke:#006600; fill:#cc0000'. | |
svg appendChild: circle. | |
document body appendChild: svg. | |
"Translated and adapted from: http://stackoverflow.com/questions/8215021/create-svg-tag-with-javascript" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment