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 ## CHANGELOG
### v2.0.3
- feat: sync element's width and height to context
### v2.0.2 ### v2.0.2
- feat: Implement CanvasTransform Interface, https://github.com/gliffy/canvas2svg/pull/83 - 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. * Draw on SVG using Canvas's 2D Context API.
* *
* Licensed under the MIT license: * Licensed under the MIT license:

View File

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