Updated Create canvas (markdown)

wout
2013-03-09 13:24:14 -08:00
parent 0fed560ac3
commit ce479ad5de

@ -32,4 +32,39 @@ if (SVG.supported) {
} else { } else {
alert('SVG not supported') alert('SVG not supported')
} }
``` ```
## ViewBox
The `viewBox` attribute of an `<svg>` element can be managed with the `viewbox()` method. When supplied with arguments it will act as a setter:
```javascript
draw.viewbox(0, 0, 297, 210)
```
Without any attributes an instance of `SVG.ViewBox` will be returned:
```javascript
var box = draw.viewbox()
```
But the best thing about the `viewbox()` method is that you can get the zoom of the viewbox:
```javascript
var box = draw.viewbox()
var zoom = box.zoom
```
If the size of the viewbox equals the size of the svg canvas, the zoom value will be 1.
## Nested svg
With this feature you can nest svg documents within each other. Nested svg documents have exactly the same features as the main, top-level svg document:
```javascript
var nested = draw.nested()
var rect = nested.rect(200, 200)
```
_This functionality requires the nested.js module which is included in the default distribution._