From 088abbe99e061de538ac7f8d56e87beb1b85a11e Mon Sep 17 00:00:00 2001 From: Gabe Lerner Date: Sat, 18 May 2019 12:32:34 -0500 Subject: [PATCH 1/4] wip --- CHANGELOG.md | 4 +++- README.md | 10 +++++----- package.json | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a13ced4ed..cafd3ce7b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,9 @@ # Change Log -## v2.0.0 (beta) +## v2.0.0 - **Breaking change**: for use on server, peer dependencies [canvas 2.x](https://github.com/Automattic/node-canvas), [jsdom 13.x](https://github.com/jsdom/jsdom) and [xmldom 0.x](https://github.com/jindw/xmldom) must be installed. +- Fix exponential notation ([#710](https://github.com/canvg/canvg/pull/710)) +- Fix font parsing ([#707](https://github.com/canvg/canvg/pull/707)) - Implement `textPath` ([#687](https://github.com/canvg/canvg/pull/687)) - Implement focal gradient radius ([#675](https://github.com/canvg/canvg/pull/675)) - Fixes 0 height rects ([#674](https://github.com/canvg/canvg/pull/674)) diff --git a/README.md b/README.md index 2c1f0dd38..4385016ab 100644 --- a/README.md +++ b/README.md @@ -43,15 +43,15 @@ Locally, you can run `npm start` and view the examples at [http://localhost:3123 ## Usage on the server -`npm install canvg@^1.5` - -**2.0.0 beta** (see [CHANGELOG](https://github.com/canvg/canvg/blob/master/CHANGELOG.md)) - -`npm install canvg@2.0.0-beta.1 canvas@^2 jsdom@^13 xmldom@^0` +`npm install canvg canvas@^2 jsdom@^13 xmldom@^0` The dependencies required on the server only are peers so must be installed alongside the canvg package. +**Older version** + +`npm install canvg@^1.5` + ## Usage on the browser For browser applications with a build process, canvg can be installed using `npm` similar to use on the server. Note in this case the peer dependencies are not required so do not need to be installed. diff --git a/package.json b/package.json index 11ef4e533..977c00f34 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "main": "dist/node/canvg.js", "types": "dist/node/canvg.d.ts", "browser": "dist/browser/canvg.min.js", - "version": "2.0.0-beta.1", + "version": "2.0.0", "scripts": { "test-browser": "ava test/browser.test.js --tap | tap-diff", "test-node": "ava test/node.test.js --tap | tap-diff", From 4b9dee30399e04eb0823169da77199cfb6d0f9d9 Mon Sep 17 00:00:00 2001 From: Gabe Lerner Date: Sat, 18 May 2019 12:33:45 -0500 Subject: [PATCH 2/4] build --- dist/browser/canvg.js | 30 +++++++++++++++------------ dist/browser/canvg.min.js | 2 +- dist/node/canvg.js | 30 +++++++++++++++------------ package-lock.json | 43 ++++++++++++++++++++++++++++----------- 4 files changed, 66 insertions(+), 39 deletions(-) diff --git a/dist/browser/canvg.js b/dist/browser/canvg.js index e6376d08d..f012c4e3b 100644 --- a/dist/browser/canvg.js +++ b/dist/browser/canvg.js @@ -1,7 +1,7 @@ /* * canvg.js - Javascript SVG parser and renderer on Canvas - * version 2.0.0-beta.1 + * version 2.0.0 * MIT Licensed * Gabe Lerner (gabelerner@gmail.com) * https://github.com/canvg/canvg @@ -498,7 +498,7 @@ // points and paths svg.ToNumberArray = function (s) { - var a = (s || '').match(/-?(\d+(\.\d+)?|\.\d+)(?=\D|$)/gm) || []; + var a = (s || '').match(/-?(\d+(?:\.\d*(?:[eE][+-]?\d+)?)?|\.\d+)(?=\D|$)/gm) || []; for (var i = 0; i < a.length; i++) { a[i] = parseFloat(a[i]); } @@ -1072,17 +1072,21 @@ // font if (typeof ctx.font != 'undefined') { - ctx.font = svg.Font.CreateFont( - this.style('font-style').value, - this.style('font-variant').value, - this.style('font-weight').value, - this.style('font-size').hasValue() ? this.style('font-size').toPixels() + 'px' : '', - this.style('font-family').value).toString(); - - // update em size if needed - var currentFontSize = this.style('font-size', false, false); - if (currentFontSize.isPixels()) { - svg.emSize = currentFontSize.toPixels(); + if (this.style('font').hasValue()) { + ctx.font = this.style('font').value; + } else { + ctx.font = svg.Font.CreateFont( + this.style('font-style').value, + this.style('font-variant').value, + this.style('font-weight').value, + this.style('font-size').hasValue() ? this.style('font-size').toPixels() + 'px' : '', + this.style('font-family').value).toString(); + + // update em size if needed + var currentFontSize = this.style('font-size', false, false); + if (currentFontSize.isPixels()) { + svg.emSize = currentFontSize.toPixels(); + } } } diff --git a/dist/browser/canvg.min.js b/dist/browser/canvg.min.js index e961b9cd7..697d435de 100644 --- a/dist/browser/canvg.min.js +++ b/dist/browser/canvg.min.js @@ -1 +1 @@ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("rgbcolor"),require("stackblur-canvas")):"function"==typeof define&&define.amd?define(["rgbcolor","stackblur-canvas"],e):t.canvg=e(t.RGBColor,t.StackBlur)}(this,function(y,v){"use strict";var t;return y=y&&y.hasOwnProperty("default")?y.default:y,v=v&&v.hasOwnProperty("default")?v.default:v,function(t){var l;t.exports;(l=window).DOMParser=window.DOMParser;var c=l.document;function d(t,e){var i;return(i=c.createElement("canvas")).width=t,i.height=e,i}var f,p=function(t,e,i){if(null!=t||null!=e||null!=i){var n=m(i||{});"string"==typeof t&&(t=c.getElementById(t)),null!=t.svg&&t.svg.stop(),t.childNodes&&1==t.childNodes.length&&"OBJECT"==t.childNodes[0].nodeName||(t.svg=n);var s=t.getContext("2d");void 0!==e.documentElement?n.loadXmlDoc(s,e):"<"==e.substr(0,1)?n.loadXml(s,e):n.load(s,e)}else for(var a=c.querySelectorAll("svg"),r=0;r~\.\[:]+)/g,a=/(\.[^\s\+>~\.\[:]+)/g,r=/(::[^\s\+>~\.\[:]+|:first-line|:first-letter|:before|:after)/gi,o=/(:[\w-]+\([^\)]*\))/gi,h=/(:[^\s\+>~\.\[:]+)/g,u=/([^\s\+>~\.\[:]+)/g;function P(n){var s=[0,0,0],t=function(t,e){var i=n.match(t);null!=i&&(s[e]+=i.length,n=n.replace(t," "))};return n=(n=n.replace(/:not\(([^\)]*)\)/g," $1 ")).replace(/{[\s\S]*/gm," "),t(e,1),t(i,0),t(a,1),t(r,2),t(o,1),t(h,1),n=(n=n.replace(/[\*\s\+>~]/g," ")).replace(/[#\.]/g," "),t(u,2),s.join("")}function m(s){var D={opts:s,FRAMERATE:30,MAX_VIRTUAL_PIXELS:3e4,rootEmSize:12,emSize:12,log:function(){}};1==D.opts.log&&"undefined"!=typeof console&&(D.log=function(t){console.log(t)}),D.init=function(t){var e=0;D.UniqueId=function(){return"canvg"+ ++e},D.Definitions={},D.Styles={},D.StylesSpecificity={},D.Animations=[],D.Images=[],D.ctx=t,D.ViewPort=new function(){this.viewPorts=[],this.Clear=function(){this.viewPorts=[]},this.SetCurrent=function(t,e){this.viewPorts.push({width:t,height:e})},this.RemoveCurrent=function(){this.viewPorts.pop()},this.Current=function(){return this.viewPorts[this.viewPorts.length-1]},this.width=function(){return this.Current().width},this.height=function(){return this.Current().height},this.ComputeSize=function(t){return null!=t&&"number"==typeof t?t:"x"==t?this.width():"y"==t?this.height():Math.sqrt(Math.pow(this.width(),2)+Math.pow(this.height(),2))/Math.sqrt(2)}}},D.init(),D.ImagesLoaded=function(){for(var t=0;t]*>/,""),(t=new ActiveXObject("Microsoft.XMLDOM")).async="false",t.loadXML(e),t;try{var n=s.xmldom?new l.DOMParser(s.xmldom):new l.DOMParser;return n.parseFromString(e,"image/svg+xml")}catch(t){return(n=s.xmldom?new l.DOMParser(s.xmldom):new l.DOMParser).parseFromString(e,"text/xml")}},D.Property=function(t,e){this.name=t,this.value=e},D.Property.prototype.getValue=function(){return this.value},D.Property.prototype.hasValue=function(){return null!=this.value&&""!==this.value},D.Property.prototype.numValue=function(){if(!this.hasValue())return 0;var t=parseFloat(this.value);return(this.value+"").match(/%$/)&&(t/=100),t},D.Property.prototype.valueOrDefault=function(t){return this.hasValue()?this.value:t},D.Property.prototype.numValueOrDefault=function(t){return this.hasValue()?this.numValue():parseFloat(t)},D.Property.prototype.addOpacity=function(t){var e=this.value;if(null!=t.value&&""!=t.value&&"string"==typeof this.value){var i=new y(this.value);i.ok&&(e="rgba("+i.r+", "+i.g+", "+i.b+", "+t.numValue()+")")}return new D.Property(this.name,e)},D.Property.prototype.getDefinition=function(){var t=this.value.match(/#([^\)'"]+)/);return t&&(t=t[1]),t||(t=this.value),D.Definitions[t]},D.Property.prototype.isUrlDefinition=function(){return 0==this.value.indexOf("url(")},D.Property.prototype.getFillStyleDefinition=function(t,e){var i=this.getDefinition();if(null!=i&&i.createGradient)return i.createGradient(D.ctx,t,e);if(null!=i&&i.createPattern){if(i.getHrefAttribute().hasValue()){var n=i.attribute("patternTransform");i=i.getHrefAttribute().getDefinition(),n.hasValue()&&(i.attribute("patternTransform",!0).value=n.value)}return i.createPattern(D.ctx,t,e)}return null},D.Property.prototype.getDPI=function(){return 96},D.Property.prototype.getREM=function(){return D.rootEmSize},D.Property.prototype.getEM=function(){return D.emSize},D.Property.prototype.getUnits=function(){return(this.value+"").replace(/[0-9\.\-]/g,"")},D.Property.prototype.isPixels=function(){if(!this.hasValue())return!1;var t=this.value+"";return!!t.match(/px$/)||!!t.match(/^[0-9]+$/)},D.Property.prototype.toPixels=function(t,e){if(!this.hasValue())return 0;var i=this.value+"";if(i.match(/rem$/))return this.numValue()*this.getREM(t);if(i.match(/em$/))return this.numValue()*this.getEM(t);if(i.match(/ex$/))return this.numValue()*this.getEM(t)/2;if(i.match(/px$/))return this.numValue();if(i.match(/pt$/))return this.numValue()*this.getDPI(t)*(1/72);if(i.match(/pc$/))return 15*this.numValue();if(i.match(/cm$/))return this.numValue()*this.getDPI(t)/2.54;if(i.match(/mm$/))return this.numValue()*this.getDPI(t)/25.4;if(i.match(/in$/))return this.numValue()*this.getDPI(t);if(i.match(/%$/))return this.numValue()*D.ViewPort.ComputeSize(t);var n=this.numValue();return e&&n<1?n*D.ViewPort.ComputeSize(t):n},D.Property.prototype.toMilliseconds=function(){return this.hasValue()?(this.value+"").match(/ms$/)?this.numValue():1e3*this.numValue():0},D.Property.prototype.toRadians=function(){if(!this.hasValue())return 0;var t=this.value+"";return t.match(/deg$/)?this.numValue()*(Math.PI/180):t.match(/grad$/)?this.numValue()*(Math.PI/200):t.match(/rad$/)?this.numValue():this.numValue()*(Math.PI/180)};var t={baseline:"alphabetic","before-edge":"top","text-before-edge":"top",middle:"middle",central:"middle","after-edge":"bottom","text-after-edge":"bottom",ideographic:"ideographic",alphabetic:"alphabetic",hanging:"hanging",mathematical:"alphabetic"};return D.Property.prototype.toTextBaseline=function(){return this.hasValue()?t[this.value]:null},D.Font=new function(){this.Styles="normal|italic|oblique|inherit",this.Variants="normal|small-caps|inherit",this.Weights="normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900|inherit",this.CreateFont=function(t,e,i,n,s,a){var r=null!=a?this.Parse(a):this.CreateFont("","","","","",D.ctx.font);return{fontFamily:s=s||r.fontFamily,fontSize:n||r.fontSize,fontStyle:t||r.fontStyle,fontWeight:i||r.fontWeight,fontVariant:e||r.fontVariant,toString:function(){return[this.fontStyle,this.fontVariant,this.fontWeight,this.fontSize,this.fontFamily].join(" ")}}};var r=this;this.Parse=function(t){for(var e={},i=D.trim(D.compressSpaces(t||"")).split(" "),n={fontSize:!1,fontStyle:!1,fontWeight:!1,fontVariant:!1},s="",a=0;athis.x2&&(this.x2=t)),null!=e&&((isNaN(this.y1)||isNaN(this.y2))&&(this.y1=e,this.y2=e),ethis.y2&&(this.y2=e))},this.addX=function(t){this.addPoint(t,null)},this.addY=function(t){this.addPoint(null,t)},this.addBoundingBox=function(t){this.addPoint(t.x1,t.y1),this.addPoint(t.x2,t.y2)},this.addQuadraticCurve=function(t,e,i,n,s,a){var r=t+2/3*(i-t),o=e+2/3*(n-e),h=r+1/3*(s-t),l=o+1/3*(a-e);this.addBezierCurve(t,e,r,h,o,l,s,a)},this.addBezierCurve=function(t,e,i,n,s,a,r,o){var h=[t,e],l=[i,n],u=[s,a],c=[r,o];this.addPoint(h[0],h[1]),this.addPoint(c[0],c[1]);for(var f=0;f<=1;f++){var p=function(t){return Math.pow(1-t,3)*h[f]+3*Math.pow(1-t,2)*t*l[f]+3*(1-t)*Math.pow(t,2)*u[f]+Math.pow(t,3)*c[f]},d=6*h[f]-12*l[f]+6*u[f],m=-3*h[f]+9*l[f]-9*u[f]+3*c[f],y=3*l[f]-3*h[f];if(0!=m){var v=Math.pow(d,2)-4*y*m;if(!(v<0)){var g=(-d+Math.sqrt(v))/(2*m);0=this.tokens.length-1},this.isCommandOrEnd=function(){return!!this.isEnd()||null!=this.tokens[this.i+1].match(/^[A-Za-z]$/)},this.isRelativeCommand=function(){switch(this.command){case"m":case"l":case"h":case"v":case"c":case"s":case"q":case"t":case"a":case"z":return!0}return!1},this.getToken=function(){return this.i++,this.tokens[this.i]},this.getScalar=function(){return parseFloat(this.getToken())},this.nextCommand=function(){this.previousCommand=this.command,this.command=this.getToken()},this.getPoint=function(){var t=new D.Point(this.getScalar(),this.getScalar());return this.makeAbsolute(t)},this.getAsControlPoint=function(){var t=this.getPoint();return this.control=t},this.getAsCurrentPoint=function(){var t=this.getPoint();return this.current=t},this.getReflectedControlPoint=function(){return"c"!=this.previousCommand.toLowerCase()&&"s"!=this.previousCommand.toLowerCase()&&"q"!=this.previousCommand.toLowerCase()&&"t"!=this.previousCommand.toLowerCase()?this.current:new D.Point(2*this.current.x-this.control.x,2*this.current.y-this.control.y)},this.makeAbsolute=function(t){return this.isRelativeCommand()&&(t.x+=this.current.x,t.y+=this.current.y),t},this.addMarker=function(t,e,i){null!=i&&0this.maxDuration){if("indefinite"==this.attribute("repeatCount").value||"indefinite"==this.attribute("repeatDur").value)this.duration=0;else if("freeze"!=this.attribute("fill").valueOrDefault("remove")||this.frozen){if("remove"==this.attribute("fill").valueOrDefault("remove")&&!this.removed)return this.removed=!0,this.getProperty().value=this.parent.animationFrozen?this.parent.animationFrozenValue:this.initialValue,!0}else this.frozen=!0,this.parent.animationFrozen=!0,this.parent.animationFrozenValue=this.getProperty().value;return!1}this.duration=this.duration+t;var e=!1;if(this.begin~\.\[:]+)/g,a=/(\.[^\s\+>~\.\[:]+)/g,r=/(::[^\s\+>~\.\[:]+|:first-line|:first-letter|:before|:after)/gi,o=/(:[\w-]+\([^\)]*\))/gi,h=/(:[^\s\+>~\.\[:]+)/g,u=/([^\s\+>~\.\[:]+)/g;function P(n){var s=[0,0,0],t=function(t,e){var i=n.match(t);null!=i&&(s[e]+=i.length,n=n.replace(t," "))};return n=(n=n.replace(/:not\(([^\)]*)\)/g," $1 ")).replace(/{[\s\S]*/gm," "),t(e,1),t(i,0),t(a,1),t(r,2),t(o,1),t(h,1),n=(n=n.replace(/[\*\s\+>~]/g," ")).replace(/[#\.]/g," "),t(u,2),s.join("")}function m(s){var D={opts:s,FRAMERATE:30,MAX_VIRTUAL_PIXELS:3e4,rootEmSize:12,emSize:12,log:function(){}};1==D.opts.log&&"undefined"!=typeof console&&(D.log=function(t){console.log(t)}),D.init=function(t){var e=0;D.UniqueId=function(){return"canvg"+ ++e},D.Definitions={},D.Styles={},D.StylesSpecificity={},D.Animations=[],D.Images=[],D.ctx=t,D.ViewPort=new function(){this.viewPorts=[],this.Clear=function(){this.viewPorts=[]},this.SetCurrent=function(t,e){this.viewPorts.push({width:t,height:e})},this.RemoveCurrent=function(){this.viewPorts.pop()},this.Current=function(){return this.viewPorts[this.viewPorts.length-1]},this.width=function(){return this.Current().width},this.height=function(){return this.Current().height},this.ComputeSize=function(t){return null!=t&&"number"==typeof t?t:"x"==t?this.width():"y"==t?this.height():Math.sqrt(Math.pow(this.width(),2)+Math.pow(this.height(),2))/Math.sqrt(2)}}},D.init(),D.ImagesLoaded=function(){for(var t=0;t]*>/,""),(t=new ActiveXObject("Microsoft.XMLDOM")).async="false",t.loadXML(e),t;try{var n=s.xmldom?new l.DOMParser(s.xmldom):new l.DOMParser;return n.parseFromString(e,"image/svg+xml")}catch(t){return(n=s.xmldom?new l.DOMParser(s.xmldom):new l.DOMParser).parseFromString(e,"text/xml")}},D.Property=function(t,e){this.name=t,this.value=e},D.Property.prototype.getValue=function(){return this.value},D.Property.prototype.hasValue=function(){return null!=this.value&&""!==this.value},D.Property.prototype.numValue=function(){if(!this.hasValue())return 0;var t=parseFloat(this.value);return(this.value+"").match(/%$/)&&(t/=100),t},D.Property.prototype.valueOrDefault=function(t){return this.hasValue()?this.value:t},D.Property.prototype.numValueOrDefault=function(t){return this.hasValue()?this.numValue():parseFloat(t)},D.Property.prototype.addOpacity=function(t){var e=this.value;if(null!=t.value&&""!=t.value&&"string"==typeof this.value){var i=new y(this.value);i.ok&&(e="rgba("+i.r+", "+i.g+", "+i.b+", "+t.numValue()+")")}return new D.Property(this.name,e)},D.Property.prototype.getDefinition=function(){var t=this.value.match(/#([^\)'"]+)/);return t&&(t=t[1]),t||(t=this.value),D.Definitions[t]},D.Property.prototype.isUrlDefinition=function(){return 0==this.value.indexOf("url(")},D.Property.prototype.getFillStyleDefinition=function(t,e){var i=this.getDefinition();if(null!=i&&i.createGradient)return i.createGradient(D.ctx,t,e);if(null!=i&&i.createPattern){if(i.getHrefAttribute().hasValue()){var n=i.attribute("patternTransform");i=i.getHrefAttribute().getDefinition(),n.hasValue()&&(i.attribute("patternTransform",!0).value=n.value)}return i.createPattern(D.ctx,t,e)}return null},D.Property.prototype.getDPI=function(){return 96},D.Property.prototype.getREM=function(){return D.rootEmSize},D.Property.prototype.getEM=function(){return D.emSize},D.Property.prototype.getUnits=function(){return(this.value+"").replace(/[0-9\.\-]/g,"")},D.Property.prototype.isPixels=function(){if(!this.hasValue())return!1;var t=this.value+"";return!!t.match(/px$/)||!!t.match(/^[0-9]+$/)},D.Property.prototype.toPixels=function(t,e){if(!this.hasValue())return 0;var i=this.value+"";if(i.match(/rem$/))return this.numValue()*this.getREM(t);if(i.match(/em$/))return this.numValue()*this.getEM(t);if(i.match(/ex$/))return this.numValue()*this.getEM(t)/2;if(i.match(/px$/))return this.numValue();if(i.match(/pt$/))return this.numValue()*this.getDPI(t)*(1/72);if(i.match(/pc$/))return 15*this.numValue();if(i.match(/cm$/))return this.numValue()*this.getDPI(t)/2.54;if(i.match(/mm$/))return this.numValue()*this.getDPI(t)/25.4;if(i.match(/in$/))return this.numValue()*this.getDPI(t);if(i.match(/%$/))return this.numValue()*D.ViewPort.ComputeSize(t);var n=this.numValue();return e&&n<1?n*D.ViewPort.ComputeSize(t):n},D.Property.prototype.toMilliseconds=function(){return this.hasValue()?(this.value+"").match(/ms$/)?this.numValue():1e3*this.numValue():0},D.Property.prototype.toRadians=function(){if(!this.hasValue())return 0;var t=this.value+"";return t.match(/deg$/)?this.numValue()*(Math.PI/180):t.match(/grad$/)?this.numValue()*(Math.PI/200):t.match(/rad$/)?this.numValue():this.numValue()*(Math.PI/180)};var t={baseline:"alphabetic","before-edge":"top","text-before-edge":"top",middle:"middle",central:"middle","after-edge":"bottom","text-after-edge":"bottom",ideographic:"ideographic",alphabetic:"alphabetic",hanging:"hanging",mathematical:"alphabetic"};return D.Property.prototype.toTextBaseline=function(){return this.hasValue()?t[this.value]:null},D.Font=new function(){this.Styles="normal|italic|oblique|inherit",this.Variants="normal|small-caps|inherit",this.Weights="normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900|inherit",this.CreateFont=function(t,e,i,n,s,a){var r=null!=a?this.Parse(a):this.CreateFont("","","","","",D.ctx.font);return{fontFamily:s=s||r.fontFamily,fontSize:n||r.fontSize,fontStyle:t||r.fontStyle,fontWeight:i||r.fontWeight,fontVariant:e||r.fontVariant,toString:function(){return[this.fontStyle,this.fontVariant,this.fontWeight,this.fontSize,this.fontFamily].join(" ")}}};var r=this;this.Parse=function(t){for(var e={},i=D.trim(D.compressSpaces(t||"")).split(" "),n={fontSize:!1,fontStyle:!1,fontWeight:!1,fontVariant:!1},s="",a=0;athis.x2&&(this.x2=t)),null!=e&&((isNaN(this.y1)||isNaN(this.y2))&&(this.y1=e,this.y2=e),ethis.y2&&(this.y2=e))},this.addX=function(t){this.addPoint(t,null)},this.addY=function(t){this.addPoint(null,t)},this.addBoundingBox=function(t){this.addPoint(t.x1,t.y1),this.addPoint(t.x2,t.y2)},this.addQuadraticCurve=function(t,e,i,n,s,a){var r=t+2/3*(i-t),o=e+2/3*(n-e),h=r+1/3*(s-t),l=o+1/3*(a-e);this.addBezierCurve(t,e,r,h,o,l,s,a)},this.addBezierCurve=function(t,e,i,n,s,a,r,o){var h=[t,e],l=[i,n],u=[s,a],c=[r,o];this.addPoint(h[0],h[1]),this.addPoint(c[0],c[1]);for(var f=0;f<=1;f++){var p=function(t){return Math.pow(1-t,3)*h[f]+3*Math.pow(1-t,2)*t*l[f]+3*(1-t)*Math.pow(t,2)*u[f]+Math.pow(t,3)*c[f]},d=6*h[f]-12*l[f]+6*u[f],m=-3*h[f]+9*l[f]-9*u[f]+3*c[f],y=3*l[f]-3*h[f];if(0!=m){var v=Math.pow(d,2)-4*y*m;if(!(v<0)){var g=(-d+Math.sqrt(v))/(2*m);0=this.tokens.length-1},this.isCommandOrEnd=function(){return!!this.isEnd()||null!=this.tokens[this.i+1].match(/^[A-Za-z]$/)},this.isRelativeCommand=function(){switch(this.command){case"m":case"l":case"h":case"v":case"c":case"s":case"q":case"t":case"a":case"z":return!0}return!1},this.getToken=function(){return this.i++,this.tokens[this.i]},this.getScalar=function(){return parseFloat(this.getToken())},this.nextCommand=function(){this.previousCommand=this.command,this.command=this.getToken()},this.getPoint=function(){var t=new D.Point(this.getScalar(),this.getScalar());return this.makeAbsolute(t)},this.getAsControlPoint=function(){var t=this.getPoint();return this.control=t},this.getAsCurrentPoint=function(){var t=this.getPoint();return this.current=t},this.getReflectedControlPoint=function(){return"c"!=this.previousCommand.toLowerCase()&&"s"!=this.previousCommand.toLowerCase()&&"q"!=this.previousCommand.toLowerCase()&&"t"!=this.previousCommand.toLowerCase()?this.current:new D.Point(2*this.current.x-this.control.x,2*this.current.y-this.control.y)},this.makeAbsolute=function(t){return this.isRelativeCommand()&&(t.x+=this.current.x,t.y+=this.current.y),t},this.addMarker=function(t,e,i){null!=i&&0this.maxDuration){if("indefinite"==this.attribute("repeatCount").value||"indefinite"==this.attribute("repeatDur").value)this.duration=0;else if("freeze"!=this.attribute("fill").valueOrDefault("remove")||this.frozen){if("remove"==this.attribute("fill").valueOrDefault("remove")&&!this.removed)return this.removed=!0,this.getProperty().value=this.parent.animationFrozen?this.parent.animationFrozenValue:this.initialValue,!0}else this.frozen=!0,this.parent.animationFrozen=!0,this.parent.animationFrozenValue=this.getProperty().value;return!1}this.duration=this.duration+t;var e=!1;if(this.begin Date: Sat, 18 May 2019 12:35:43 -0500 Subject: [PATCH 3/4] npm audit --- package-lock.json | 18 +++++++++--------- package.json | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/package-lock.json b/package-lock.json index 42b28bf74..109437dae 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3623,9 +3623,9 @@ "dev": true }, "js-yaml": { - "version": "3.12.1", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.12.1.tgz", - "integrity": "sha512-um46hB9wNOKlwkHgiuyEVAybXBjwFUV0Z/RaHJblRd9DXltue9FTYvzCr9ErQrK9Adz5MU4gHWVaNUfdmrC8qA==", + "version": "3.13.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", + "integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==", "dev": true, "requires": { "argparse": "^1.0.7", @@ -4019,9 +4019,9 @@ } }, "mime": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/mime/-/mime-2.4.0.tgz", - "integrity": "sha512-ikBcWwyqXQSHKtciCcctu9YfPbFYZ4+gbHEmE0Q8jzcTYQg5dHCr3g2wwAZjPoJfQVXZq6KXAjpXOTf5/cjT7w==", + "version": "2.4.3", + "resolved": "https://registry.npmjs.org/mime/-/mime-2.4.3.tgz", + "integrity": "sha512-QgrPRJfE+riq5TPZMcHZOtm8c6K/yYrMbKIoRfapfiGLxS8OTeIfRhUGW5LU7MlRa52KOAGCfUNruqLrIBvWZw==", "dev": true }, "mime-db": { @@ -4846,9 +4846,9 @@ "dev": true }, "puppeteer": { - "version": "1.12.2", - "resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-1.12.2.tgz", - "integrity": "sha512-xWSyCeD6EazGlfnQweMpM+Hs6X6PhUYhNTHKFj/axNZDq4OmrVERf70isBf7HsnFgB3zOC1+23/8+wCAZYg+Pg==", + "version": "1.16.0", + "resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-1.16.0.tgz", + "integrity": "sha512-7hcmbUw+6INffSPBdnO8KSjJRg2bLRoI7EeZMf5MHdV5kpyYMeoMR5w8AIiZbKIhYGwrXlbgvO7gFTsXNHShuQ==", "dev": true, "requires": { "debug": "^4.1.0", diff --git a/package.json b/package.json index 977c00f34..bf7fe4750 100644 --- a/package.json +++ b/package.json @@ -71,7 +71,7 @@ "jsdom": "^13.0.0", "mkdirp": "^0.5.1", "pngjs-image": "^0.11.7", - "puppeteer": "^1.10.0", + "puppeteer": "^1.16.0", "rollup": "^0.67.3", "rollup-plugin-alias": "^1.4.0", "rollup-plugin-commonjs": "^9.2.0", From 9eb51a54c1e4330f43cc06988fea9ffef95c37f4 Mon Sep 17 00:00:00 2001 From: Gabe Lerner Date: Sat, 18 May 2019 12:37:40 -0500 Subject: [PATCH 4/4] rm beta --- README.md | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/README.md b/README.md index 4385016ab..669486e7d 100644 --- a/README.md +++ b/README.md @@ -66,16 +66,6 @@ Alternatively, canvg can be included directly into a webpage: ``` -For the **2.0.0 beta** (see [CHANGELOG](https://github.com/canvg/canvg/blob/master/CHANGELOG.md)), use this: -```html - - - - - - -``` - Put a canvas on your page ```html