mirror of
https://github.com/svgdotjs/svg.js.git
synced 2025-10-27 18:44:44 +08:00
Updated Create canvas (markdown)
@ -33,3 +33,38 @@ if (SVG.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._
|
||||
Reference in New Issue
Block a user