ctx-polyfill
Advanced tools
Comparing version 1.1.1 to 1.1.2
@@ -11,2 +11,3 @@ (function() { | ||
CanvasRenderingContext2D.arrayToSVGMatrix = function(array) { | ||
if(array instanceof SVGMatrix) return array; | ||
var matrix = document.createElementNS('http://www.w3.org/2000/svg', 'svg').createSVGMatrix(); | ||
@@ -23,2 +24,3 @@ matrix.a = array[0]; | ||
CanvasRenderingContext2D.svgMatrixToArray = function(matrix) { | ||
if(matrix instanceof Array) return matrix; | ||
if(!(matrix instanceof SVGMatrix)) throw new Error('Matrix is not a SVGMatrix'); | ||
@@ -35,2 +37,3 @@ return [ | ||
})(); | ||
@@ -43,5 +46,6 @@ | ||
// inspired form https://github.com/mozilla/pdf.js/blob/master/src/display/canvas.js | ||
// inspired form https://github.com/mozilla/pdf.js/blob/master/src/display/canvas.js | ||
var canvasRenderingContext2DPrototype = CanvasRenderingContext2D.prototype; | ||
var HTMLCanvasElementPrototype = HTMLCanvasElement.prototype; | ||
@@ -69,10 +73,11 @@ if(!('resetTransform' in canvasRenderingContext2DPrototype)) { | ||
} else { | ||
var getContext = HTMLCanvasElement.prototype.getContext; | ||
HTMLCanvasElement.prototype.getContext = function(contextType, contextAttributes) { | ||
var getContext = HTMLCanvasElementPrototype.getContext; | ||
HTMLCanvasElementPrototype.getContext = function(contextType, contextAttributes) { | ||
var context = getContext.call(this, contextType, contextAttributes); | ||
switch(contextType) { | ||
case '2d': | ||
context._transformStack = []; | ||
context._transformMatrix = [ 1, 0, 0, 1, 0, 0 ]; | ||
Object.defineProperties(context, { | ||
'_transformStack': { value: [], configurable: true, writable: true }, | ||
'_transformMatrix': { value: [1, 0, 0, 1, 0, 0], configurable: true, writable: true } | ||
}); | ||
break; | ||
@@ -83,5 +88,4 @@ } | ||
Object.defineProperty(canvasRenderingContext2DPrototype, 'currentTransform', { | ||
get: function () { | ||
get: function() { | ||
return CanvasRenderingContext2D.useSvgMatrix ? | ||
@@ -91,11 +95,12 @@ CanvasRenderingContext2D.arrayToSVGMatrix(this._transformMatrix) : this._transformMatrix; | ||
set: function(matrix) { | ||
this._transformMatrix = CanvasRenderingContext2D.useSvgMatrix ? | ||
matrix = CanvasRenderingContext2D.useSvgMatrix ? | ||
CanvasRenderingContext2D.svgMatrixToArray(matrix) : matrix; | ||
this._transformMatrix = matrix; | ||
this.setTransform( | ||
this._transformMatrix[0], | ||
this._transformMatrix[1], | ||
this._transformMatrix[2], | ||
this._transformMatrix[3], | ||
this._transformMatrix[4], | ||
this._transformMatrix[5] | ||
matrix[0], | ||
matrix[1], | ||
matrix[2], | ||
matrix[3], | ||
matrix[4], | ||
matrix[5] | ||
); | ||
@@ -146,3 +151,3 @@ }, | ||
canvasRenderingContext2DPrototype.transform = function(a, b, c, d, e, f) { | ||
var matrix = this._transformMatrix; | ||
var matrix = this._transformMatrix; | ||
this._transformMatrix = [ | ||
@@ -160,3 +165,3 @@ matrix[0] * a + matrix[2] * b, | ||
var setTransform = canvasRenderingContext2DPrototype.setTransform; | ||
canvasRenderingContext2DPrototype.setTransform = function(a, b, c, d, e, f) { | ||
canvasRenderingContext2DPrototype.setTransform = function(a, b, c, d, e, f) { | ||
this._transformMatrix = [a, b, c, d, e, f]; | ||
@@ -167,3 +172,3 @@ setTransform.call(this, a, b, c, d, e, f); | ||
var resetTransform = canvasRenderingContext2DPrototype.resetTransform; | ||
canvasRenderingContext2DPrototype.resetTransform = function() { | ||
canvasRenderingContext2DPrototype.resetTransform = function() { | ||
this._transformMatrix = [1, 0, 0, 1, 0, 0]; | ||
@@ -176,3 +181,3 @@ resetTransform.call(this); | ||
this._transformStack.push(this._transformMatrix); | ||
this._transformMatrix = this._transformMatrix.slice(0, 6); // copy | ||
this._transformMatrix = this._transformMatrix.slice(0, 6); // copy | ||
save.call(this); | ||
@@ -189,3 +194,3 @@ }; | ||
}; | ||
} | ||
@@ -196,3 +201,3 @@ } | ||
Object.defineProperty(canvasRenderingContext2DPrototype, 'imageSmoothingEnabled', { | ||
get: function () { | ||
get: function() { | ||
if(this.mozImageSmoothingEnabled !== void 0) { | ||
@@ -242,2 +247,25 @@ return this.mozImageSmoothingEnabled; | ||
// if(!('addHitRegion' in canvasRenderingContext2DPrototype)) { | ||
// var getContext = HTMLCanvasElementPrototype.getContext; | ||
// HTMLCanvasElementPrototype.getContext = function(contextType, contextAttributes) { | ||
// var context = getContext.call(this, contextType, contextAttributes); | ||
// switch(contextType) { | ||
// case '2d': | ||
// Object.defineProperties(context, { | ||
// '_hitRegions': { value: [], configurable: true, writable: true } | ||
// }); | ||
// break; | ||
// } | ||
// return context; | ||
// }; | ||
// | ||
// HTMLCanvasElementPrototype.addEventListener = function() { | ||
// | ||
// }; | ||
// | ||
// canvasRenderingContext2DPrototype.addHitRegion = function(options) { | ||
// | ||
// } | ||
// } | ||
})(); | ||
@@ -249,27 +277,44 @@ | ||
*/ | ||
if(!('Path2D' in window) || !('addPath' in window.Path2D.prototype)) { | ||
var supportNativePath2D = ('Path2D' in window); | ||
var _Path2D = window.Path2D; | ||
// polyfill Path2D class | ||
if(!supportNativePath2D) { | ||
Path2D = function(path2D) { | ||
if(path2D instanceof Path2D) { | ||
var Path2D = function(path2D) { | ||
Object.defineProperty(this, '_operations', { | ||
value: [], | ||
configurable: true, | ||
writable: true | ||
}); | ||
if(path2D instanceof Path2D) { | ||
if(path2D._original && _Path2D) { | ||
Object.defineProperty(this, '_original', { | ||
// value: new (_Path2D.bind.apply(_Path2D, [path2D._original].concat(Array.prototype.slice.call(arguments, 1)))), | ||
// value: new (Function.prototype.bind.apply(_Path2D, [path2D._original].concat(Array.prototype.slice.call(arguments, 1)))), | ||
value: new _Path2D(path2D._original), | ||
configurable: true, | ||
writable: true | ||
}); | ||
this._operations = path2D._operations.slice(0); | ||
} else { | ||
this.addPath(path2D); | ||
} | ||
}; | ||
window.Path2D = Path2D; | ||
} | ||
} else if(_Path2D) { | ||
Object.defineProperty(this, '_original', { | ||
value: new _Path2D(path2D), | ||
configurable: true, | ||
writable: true | ||
}); | ||
} | ||
}; | ||
var path2DPrototype = window.Path2D.prototype; | ||
window.Path2D = Path2D; | ||
var path2DPrototype = Path2D.prototype; | ||
// save all operations for the path | ||
Object.defineProperty(path2DPrototype, '_operations', { value: [] }); | ||
['arc', 'arcTo', 'bezierCurveTo', 'closePath', 'ellipse', 'lineTo', 'moveTo', 'quadraticCurveTo', 'rect'] | ||
.forEach(function(attributeName) { | ||
var original = path2DPrototype[attributeName]; | ||
path2DPrototype[attributeName] = function() { | ||
this._operations.push({ type: attributeName, arguments: Array.prototype.slice.call(arguments, 0) }); | ||
if(supportNativePath2D) original.apply(this, arguments); | ||
if(this._original) _Path2D.prototype[attributeName].apply(this._original, arguments); | ||
}; | ||
@@ -279,9 +324,11 @@ }); | ||
// polyfill CanvasRenderingContext2D drawing Path2D | ||
if(!supportNativePath2D) { | ||
var canvasRenderingContext2DPrototype = CanvasRenderingContext2D.prototype; | ||
['fill', 'stroke', 'clip', 'isPointInPath', 'isPointInStroke'] | ||
.forEach(function(attributeName) { | ||
var original = canvasRenderingContext2DPrototype[attributeName]; | ||
canvasRenderingContext2DPrototype[attributeName] = function(path2D) { | ||
if(path2D instanceof Path2D) { | ||
var canvasRenderingContext2DPrototype = CanvasRenderingContext2D.prototype; | ||
['fill', 'stroke', 'clip', 'isPointInPath', 'isPointInStroke'] | ||
.forEach(function(attributeName) { | ||
var original = canvasRenderingContext2DPrototype[attributeName]; | ||
canvasRenderingContext2DPrototype[attributeName] = function(path2D) { | ||
if(path2D instanceof Path2D) { | ||
if(path2D._original) { | ||
original.apply(this, [path2D._original].concat(Array.prototype.slice.call(arguments, 1))); | ||
} else { | ||
this.beginPath(); | ||
@@ -294,9 +341,10 @@ var operation; | ||
original.apply(this, Array.prototype.slice.call(arguments, 1)); | ||
} else { | ||
original.apply(this, arguments); | ||
} | ||
}; | ||
}); | ||
} | ||
} else { | ||
original.apply(this, arguments); | ||
} | ||
}; | ||
}); | ||
// polyfill addPath | ||
@@ -306,4 +354,3 @@ if(!('addPath' in path2DPrototype)) { | ||
if(transform !== void 0) { | ||
if(supportNativePath2D) throw new Error('Transform is not supported yet on native Path2D addPath.'); | ||
if(path2D._original) delete path2D._original; | ||
this._operations.push({ type: 'save', arguments: [] }); | ||
@@ -330,2 +377,32 @@ this._operations.push({ | ||
} | ||
})(); | ||
})(); | ||
// (function() { | ||
// window.addEventListener('load', function() { | ||
// var canvas = document.getElementById('canvas'); | ||
// var ctx = canvas.getContext('2d'); | ||
// | ||
// canvas.addEventListener('mousemove', function(event) { | ||
// if(event.region) { | ||
// console.log(event.region); | ||
// } | ||
// }); | ||
// | ||
// ctx.beginPath(); | ||
// ctx.arc(100, 100, 75, 0, 2 * Math.PI, false); | ||
// ctx.lineWidth = 5; | ||
// ctx.stroke(); | ||
// | ||
// // eyes | ||
// ctx.beginPath(); | ||
// ctx.arc(70, 80, 10, 0, 2 * Math.PI, false); | ||
// ctx.arc(130, 80, 10, 0, 2 * Math.PI, false); | ||
// ctx.fill(); | ||
// ctx.addHitRegion({id: "eyes"}); | ||
// | ||
// // mouth | ||
// ctx.beginPath(); | ||
// ctx.arc(100, 110, 50, 0, Math.PI, false); | ||
// ctx.stroke(); | ||
// }); | ||
// })(); |
@@ -1,1 +0,1 @@ | ||
(function(){if(CanvasRenderingContext2D.useSvgMatrix===void 0){CanvasRenderingContext2D.useSvgMatrix=false}CanvasRenderingContext2D.arrayToSVGMatrix=function(t){var r=document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGMatrix();r.a=t[0];r.b=t[1];r.c=t[2];r.d=t[3];r.e=t[4];r.f=t[5];return r};CanvasRenderingContext2D.svgMatrixToArray=function(t){if(!(t instanceof SVGMatrix))throw new Error("Matrix is not a SVGMatrix");return[t.a,t.b,t.c,t.d,t.e,t.f]}})();(function(){var t=CanvasRenderingContext2D.prototype;if(!("resetTransform"in t)){t.resetTransform=function(){this.setTransform(1,0,0,1,0,0)}}if(!("currentTransform"in t)){if("mozCurrentTransform"in t){Object.defineProperty(t,"currentTransform",{get:function(){return CanvasRenderingContext2D.useSvgMatrix?CanvasRenderingContext2D.arrayToSVGMatrix(this.mozCurrentTransform):this.mozCurrentTransform},set:function(t){this.mozCurrentTransform=CanvasRenderingContext2D.useSvgMatrix?CanvasRenderingContext2D.svgMatrixToArray(t):t},enumerable:true,configurable:true})}else{var r=HTMLCanvasElement.prototype.getContext;HTMLCanvasElement.prototype.getContext=function(t,a){var n=r.call(this,t,a);switch(t){case"2d":n._transformStack=[];n._transformMatrix=[1,0,0,1,0,0];break}return n};Object.defineProperty(t,"currentTransform",{get:function(){return CanvasRenderingContext2D.useSvgMatrix?CanvasRenderingContext2D.arrayToSVGMatrix(this._transformMatrix):this._transformMatrix},set:function(t){this._transformMatrix=CanvasRenderingContext2D.useSvgMatrix?CanvasRenderingContext2D.svgMatrixToArray(t):t;this.setTransform(this._transformMatrix[0],this._transformMatrix[1],this._transformMatrix[2],this._transformMatrix[3],this._transformMatrix[4],this._transformMatrix[5])},enumerable:true,configurable:true});var a=t.translate;t.translate=function(t,r){var n=this._transformMatrix;n[4]=n[0]*t+n[2]*r+n[4];n[5]=n[1]*t+n[3]*r+n[5];a.call(this,t,r)};var n=t.scale;t.scale=function(t,r){var a=this._transformMatrix;a[0]*=t;a[1]*=t;a[2]*=r;a[3]*=r;n.call(this,t,r)};var e=t.rotate;t.rotate=function(t){var r=Math.cos(t);var a=Math.sin(t);var n=this._transformMatrix;this._transformMatrix=[n[0]*r+n[2]*a,n[1]*r+n[3]*a,n[0]*-a+n[2]*r,n[1]*-a+n[3]*r,n[4],n[5]];e.call(this,t)};var i=t.transform;t.transform=function(t,r,a,n,e,o){var s=this._transformMatrix;this._transformMatrix=[s[0]*t+s[2]*r,s[1]*t+s[3]*r,s[0]*a+s[2]*n,s[1]*a+s[3]*n,s[0]*e+s[2]*o+s[4],s[1]*e+s[3]*o+s[5]];i.call(this,t,r,a,n,e,o)};var o=t.setTransform;t.setTransform=function(t,r,a,n,e,i){this._transformMatrix=[t,r,a,n,e,i];o.call(this,t,r,a,n,e,i)};var s=t.resetTransform;t.resetTransform=function(){this._transformMatrix=[1,0,0,1,0,0];s.call(this)};var f=t.save;t.save=function(){this._transformStack.push(this._transformMatrix);this._transformMatrix=this._transformMatrix.slice(0,6);f.call(this)};var h=t.restore;t.restore=function(){var t=this._transformStack.pop();if(t){this._transformMatrix=t}h.call(this)}}}if(!("imageSmoothingEnabled"in t)){Object.defineProperty(t,"imageSmoothingEnabled",{get:function(){if(this.mozImageSmoothingEnabled!==void 0){return this.mozImageSmoothingEnabled}else if(this.webkitImageSmoothingEnabled!==void 0){return this.webkitImageSmoothingEnabled}else if(this.msImageSmoothingEnabled!==void 0){return this.msImageSmoothingEnabled}else{return true}},set:function(t){if(this.mozImageSmoothingEnabled!==void 0){this.mozImageSmoothingEnabled=t}else if(this.webkitImageSmoothingEnabled!==void 0){this.webkitImageSmoothingEnabled=t}else if(this.msImageSmoothingEnabled!==void 0){this.msImageSmoothingEnabled=t}},enumerable:true,configurable:true})}if(!("ellipse"in t)){t.ellipse=function(t,r,a,n,e,i,o,s){this.save();this.translate(t,r);this.rotate(e);this.scale(a,n);this.arc(0,0,1,i,o,s);this.restore()}}})();(function(){if(!("Path2D"in window)||!("addPath"in window.Path2D.prototype)){var t="Path2D"in window;if(!t){Path2D=function(t){if(t instanceof Path2D){this.addPath(t)}};window.Path2D=Path2D}var r=window.Path2D.prototype;Object.defineProperty(r,"_operations",{value:[]});["arc","arcTo","bezierCurveTo","closePath","ellipse","lineTo","moveTo","quadraticCurveTo","rect"].forEach(function(a){var n=r[a];r[a]=function(){this._operations.push({type:a,arguments:Array.prototype.slice.call(arguments,0)});if(t)n.apply(this,arguments)}});if(!t){var a=CanvasRenderingContext2D.prototype;["fill","stroke","clip","isPointInPath","isPointInStroke"].forEach(function(t){var r=a[t];a[t]=function(t){if(t instanceof Path2D){this.beginPath();var n;for(var e=0,i=t._operations.length;e<i;e++){n=t._operations[e];a[n.type].apply(this,n.arguments)}r.apply(this,Array.prototype.slice.call(arguments,1))}else{r.apply(this,arguments)}}})}if(!("addPath"in r)){r.addPath=function(a,n){if(n!==void 0){if(t)throw new Error("Transform is not supported yet on native Path2D addPath.");this._operations.push({type:"save",arguments:[]});this._operations.push({type:"transform",arguments:CanvasRenderingContext2D.useSvgMatrix?CanvasRenderingContext2D.svgMatrixToArray(n):n})}var e;for(var i=0,o=a._operations.length;i<o;i++){e=a._operations[i];r[e.type].apply(this,e.arguments)}if(n!==void 0){this._operations.push({type:"restore",arguments:[]})}}}}})(); | ||
(function(){if(CanvasRenderingContext2D.useSvgMatrix===void 0){CanvasRenderingContext2D.useSvgMatrix=false}CanvasRenderingContext2D.arrayToSVGMatrix=function(t){if(t instanceof SVGMatrix)return t;var r=document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGMatrix();r.a=t[0];r.b=t[1];r.c=t[2];r.d=t[3];r.e=t[4];r.f=t[5];return r};CanvasRenderingContext2D.svgMatrixToArray=function(t){if(t instanceof Array)return t;if(!(t instanceof SVGMatrix))throw new Error("Matrix is not a SVGMatrix");return[t.a,t.b,t.c,t.d,t.e,t.f]}})();(function(){var t=CanvasRenderingContext2D.prototype;var r=HTMLCanvasElement.prototype;if(!("resetTransform"in t)){t.resetTransform=function(){this.setTransform(1,0,0,1,0,0)}}if(!("currentTransform"in t)){if("mozCurrentTransform"in t){Object.defineProperty(t,"currentTransform",{get:function(){return CanvasRenderingContext2D.useSvgMatrix?CanvasRenderingContext2D.arrayToSVGMatrix(this.mozCurrentTransform):this.mozCurrentTransform},set:function(t){this.mozCurrentTransform=CanvasRenderingContext2D.useSvgMatrix?CanvasRenderingContext2D.svgMatrixToArray(t):t},enumerable:true,configurable:true})}else{var e=r.getContext;r.getContext=function(t,r){var a=e.call(this,t,r);switch(t){case"2d":Object.defineProperties(a,{_transformStack:{value:[],configurable:true,writable:true},_transformMatrix:{value:[1,0,0,1,0,0],configurable:true,writable:true}});break}return a};Object.defineProperty(t,"currentTransform",{get:function(){return CanvasRenderingContext2D.useSvgMatrix?CanvasRenderingContext2D.arrayToSVGMatrix(this._transformMatrix):this._transformMatrix},set:function(t){t=CanvasRenderingContext2D.useSvgMatrix?CanvasRenderingContext2D.svgMatrixToArray(t):t;this._transformMatrix=t;this.setTransform(t[0],t[1],t[2],t[3],t[4],t[5])},enumerable:true,configurable:true});var a=t.translate;t.translate=function(t,r){var e=this._transformMatrix;e[4]=e[0]*t+e[2]*r+e[4];e[5]=e[1]*t+e[3]*r+e[5];a.call(this,t,r)};var n=t.scale;t.scale=function(t,r){var e=this._transformMatrix;e[0]*=t;e[1]*=t;e[2]*=r;e[3]*=r;n.call(this,t,r)};var i=t.rotate;t.rotate=function(t){var r=Math.cos(t);var e=Math.sin(t);var a=this._transformMatrix;this._transformMatrix=[a[0]*r+a[2]*e,a[1]*r+a[3]*e,a[0]*-e+a[2]*r,a[1]*-e+a[3]*r,a[4],a[5]];i.call(this,t)};var o=t.transform;t.transform=function(t,r,e,a,n,i){var s=this._transformMatrix;this._transformMatrix=[s[0]*t+s[2]*r,s[1]*t+s[3]*r,s[0]*e+s[2]*a,s[1]*e+s[3]*a,s[0]*n+s[2]*i+s[4],s[1]*n+s[3]*i+s[5]];o.call(this,t,r,e,a,n,i)};var s=t.setTransform;t.setTransform=function(t,r,e,a,n,i){this._transformMatrix=[t,r,e,a,n,i];s.call(this,t,r,e,a,n,i)};var f=t.resetTransform;t.resetTransform=function(){this._transformMatrix=[1,0,0,1,0,0];f.call(this)};var l=t.save;t.save=function(){this._transformStack.push(this._transformMatrix);this._transformMatrix=this._transformMatrix.slice(0,6);l.call(this)};var h=t.restore;t.restore=function(){var t=this._transformStack.pop();if(t){this._transformMatrix=t}h.call(this)}}}if(!("imageSmoothingEnabled"in t)){Object.defineProperty(t,"imageSmoothingEnabled",{get:function(){if(this.mozImageSmoothingEnabled!==void 0){return this.mozImageSmoothingEnabled}else if(this.webkitImageSmoothingEnabled!==void 0){return this.webkitImageSmoothingEnabled}else if(this.msImageSmoothingEnabled!==void 0){return this.msImageSmoothingEnabled}else{return true}},set:function(t){if(this.mozImageSmoothingEnabled!==void 0){this.mozImageSmoothingEnabled=t}else if(this.webkitImageSmoothingEnabled!==void 0){this.webkitImageSmoothingEnabled=t}else if(this.msImageSmoothingEnabled!==void 0){this.msImageSmoothingEnabled=t}},enumerable:true,configurable:true})}if(!("ellipse"in t)){t.ellipse=function(t,r,e,a,n,i,o,s){this.save();this.translate(t,r);this.rotate(n);this.scale(e,a);this.arc(0,0,1,i,o,s);this.restore()}}})();(function(){if(!("Path2D"in window)||!("addPath"in window.Path2D.prototype)){var t=window.Path2D;var r=function(e){Object.defineProperty(this,"_operations",{value:[],configurable:true,writable:true});if(e instanceof r){if(e._original&&t){Object.defineProperty(this,"_original",{value:new t(e._original),configurable:true,writable:true});this._operations=e._operations.slice(0)}else{this.addPath(e)}}else if(t){Object.defineProperty(this,"_original",{value:new t(e),configurable:true,writable:true})}};window.Path2D=r;var e=r.prototype;["arc","arcTo","bezierCurveTo","closePath","ellipse","lineTo","moveTo","quadraticCurveTo","rect"].forEach(function(r){e[r]=function(){this._operations.push({type:r,arguments:Array.prototype.slice.call(arguments,0)});if(this._original)t.prototype[r].apply(this._original,arguments)}});var a=CanvasRenderingContext2D.prototype;["fill","stroke","clip","isPointInPath","isPointInStroke"].forEach(function(t){var e=a[t];a[t]=function(t){if(t instanceof r){if(t._original){e.apply(this,[t._original].concat(Array.prototype.slice.call(arguments,1)))}else{this.beginPath();var n;for(var i=0,o=t._operations.length;i<o;i++){n=t._operations[i];a[n.type].apply(this,n.arguments)}e.apply(this,Array.prototype.slice.call(arguments,1))}}else{e.apply(this,arguments)}}});if(!("addPath"in e)){e.addPath=function(t,r){if(r!==void 0){if(t._original)delete t._original;this._operations.push({type:"save",arguments:[]});this._operations.push({type:"transform",arguments:CanvasRenderingContext2D.useSvgMatrix?CanvasRenderingContext2D.svgMatrixToArray(r):r})}var a;for(var n=0,i=t._operations.length;n<i;n++){a=t._operations[n];e[a.type].apply(this,a.arguments)}if(r!==void 0){this._operations.push({type:"restore",arguments:[]})}}}}})(); |
{ | ||
"name": "ctx-polyfill", | ||
"version": "1.1.1", | ||
"version": "1.1.2", | ||
"description": "Polyfill CanvasRenderingContext2D and Path2D (currentTransform, resetTransform, imageSmoothingEnabled, etc...)", | ||
@@ -5,0 +5,0 @@ "main": "ctx-polyfill.js", |
@@ -23,9 +23,6 @@ ### Polyfill CanvasRenderingContext2D and Path2Dto match last ES7 specifications | ||
Experimental: [addPath](https://developer.mozilla.org/en-US/docs/Web/API/Path2D/addPath). | ||
With **native** Path2D, `addPath` does not support yet a `transform` argument. If you absolutely need it, do : `delete window.Path2D`, the polyfill will build it's own Path2D class. | ||
For size reasons, Path2D polyfill does'nt support SVG path (used as argument in constructor). | ||
#### Helper | ||
Because the specs are not finished, the `currentTransform` or even `Path2D.addPath`originally used [SVGMatrix](https://developer.mozilla.org/en-US/docs/Web/API/SVGMatrix) which have beed deprecated. Instead, use an Array[6]. | ||
Because the specs are not finished, the `currentTransform` or even `Path2D.addPath`originally used [SVGMatrix](https://developer.mozilla.org/en-US/docs/Web/API/SVGMatrix) which have been deprecated. Instead, use an Array[6]. | ||
@@ -32,0 +29,0 @@ If you need SVGMatrix, some hacks have been implemented : |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
22496
5
347
42
1