feat: sync element's width and height to context

This commit is contained in:
Zeno Zeng 2021-06-14 21:45:27 +08:00
parent 134e9c52cb
commit 3e7435eec8
3 changed files with 7 additions and 5 deletions

View File

@ -28,6 +28,10 @@ const mySerializedSVG = ctx.getSerializedSvg();
## CHANGELOG
### v2.0.3
- feat: sync element's width and height to context
### v2.0.2
- feat: Implement CanvasTransform Interface, https://github.com/gliffy/canvas2svg/pull/83

View File

@ -1,5 +1,5 @@
/*!!
* SVGCanvas v2.0.1
* SVGCanvas v2.0.3
* Draw on SVG using Canvas's 2D Context API.
*
* Licensed under the MIT license:

View File

@ -2,9 +2,7 @@ import Context from './context';
function SVGCanvasElement(options) {
var debug = options && options.debug;
this.ctx = new Context(100, 100, {debug: debug});
this.ctx = new Context(100, 100);
this.svg = this.ctx.__root;
// sync attributes to svg
@ -34,7 +32,7 @@ function SVGCanvasElement(options) {
if (isNaN(val) || (typeof val === "undefined")) {
return;
}
_this.ctx['__'+prop] = val;
_this.ctx[prop] = val;
svg.setAttribute(prop, val);
return wrapper[prop] = val;
}