From ce479ad5de5033e1cd40460748399ee843d6c6b8 Mon Sep 17 00:00:00 2001 From: wout Date: Sat, 9 Mar 2013 13:24:14 -0800 Subject: [PATCH] Updated Create canvas (markdown) --- Create-canvas.md => SVG-canvases.md | 37 ++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) rename Create-canvas.md => SVG-canvases.md (50%) diff --git a/Create-canvas.md b/SVG-canvases.md similarity index 50% rename from Create-canvas.md rename to SVG-canvases.md index 2978f64..2b0bc36 100644 --- a/Create-canvas.md +++ b/SVG-canvases.md @@ -32,4 +32,39 @@ if (SVG.supported) { } else { alert('SVG not supported') } -``` \ No newline at end of file +``` + +## ViewBox + +The `viewBox` attribute of an `` 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._