canvas-5-polyfill
Advanced tools
Comparing version
@@ -12,2 +12,7 @@ /** | ||
*/ | ||
var CanvasRenderingContext2D = CanvasRenderingContext2D; | ||
if (CanvasRenderingContext2D == undefined) { | ||
CanvasRenderingContext2D = require('canvas').Context2d; | ||
} | ||
if (CanvasRenderingContext2D.prototype.ellipse == undefined) { | ||
@@ -24,3 +29,4 @@ CanvasRenderingContext2D.prototype.ellipse = function(x, y, radiusX, radiusY, rotation, startAngle, endAngle, antiClockwise) { | ||
if (typeof Path2D !== 'function') { | ||
if (typeof Path2D !== 'function' || | ||
typeof new Path2D().addPath !== 'function') { | ||
(function() { | ||
@@ -82,8 +88,8 @@ | ||
if (tr | ||
&& tr.hasOwnProperty('a') | ||
&& tr.hasOwnProperty('b') | ||
&& tr.hasOwnProperty('c') | ||
&& tr.hasOwnProperty('d') | ||
&& tr.hasOwnProperty('e') | ||
&& tr.hasOwnProperty('f')) { | ||
&& tr.a != undefined | ||
&& tr.b != undefined | ||
&& tr.c != undefined | ||
&& tr.d != undefined | ||
&& tr.e != undefined | ||
&& tr.f != undefined) { | ||
hasTx = true; | ||
@@ -90,0 +96,0 @@ this.ops_.push({type: 'save', args: []}); |
{ | ||
"name": "canvas-5-polyfill", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"description": "Polyfill for HTML 5 Canvas features.", | ||
"main": "canvas.js", | ||
"types": "./canvas.d.ts", | ||
"directories": { | ||
@@ -7,0 +8,0 @@ "test": "test" |
@@ -9,3 +9,3 @@ # Canvas 5 Polyfill | ||
Canvas 5 Polyfill uses [http://bower.io/](Bower) to make installation easy: | ||
Canvas 5 Polyfill uses [Bower](http://bower.io/) to make installation easy: | ||
@@ -16,3 +16,3 @@ ``` | ||
You can also get the code directly at [https://github.com/google/canvas-5-polyfill](GitHub). | ||
You can also get the code directly at [GitHub](https://github.com/google/canvas-5-polyfill). | ||
@@ -19,0 +19,0 @@ ## Usage |
@@ -122,5 +122,5 @@ parser = (function() { | ||
}, | ||
peg$c37 = function(rx, ry, xrot, large, sweep, last) { return [parseFloat(rx), parseFloat(ry), parseFloat(xrot.join('')), parseInt(large), parseInt(sweep), last[0], last[1]]; }, | ||
peg$c37 = function(rx, ry, xrot, large, sweep, last) { return [parseFloat(rx), parseFloat(ry), parseFloat(flatten(xrot).join('')), parseInt(large), parseInt(sweep), last[0], last[1]]; }, | ||
peg$c38 = function(x, y) { return [x, y] }, | ||
peg$c39 = function(number) { return parseFloat(number.join('')) }, | ||
peg$c39 = function(number) { return parseFloat(flatten(number).join('')) }, | ||
peg$c40 = "0", | ||
@@ -1871,2 +1871,15 @@ peg$c41 = { type: "literal", value: "0", description: "\"0\"" }, | ||
// Flatten an array. | ||
function flatten(a) { | ||
var flat = []; | ||
for (var i = 0; i < a.length; i++) { | ||
if (a[i] instanceof Array) { | ||
flat.push.apply(flat, flatten(a[i])); | ||
} else { | ||
flat.push(a[i]); | ||
} | ||
} | ||
return flat; | ||
} | ||
// Convert a position into an absolute position. | ||
@@ -1873,0 +1886,0 @@ function makeAbsolute(c, coord) { |
@@ -8,2 +8,6 @@ describe('AddPath Test Suite.', | ||
var path = new Path2D(); | ||
if (path.ops_ == undefined) { | ||
// Don't bother testing a native Path2D impl. | ||
return | ||
} | ||
var toadd = new Path2D(); | ||
@@ -19,2 +23,6 @@ toadd.rect(0, 0, 100, 100); | ||
var path = new Path2D(); | ||
if (path.ops_ == undefined) { | ||
// Don't bother testing a native Path2D impl. | ||
return | ||
} | ||
var toadd = new Path2D(); | ||
@@ -21,0 +29,0 @@ toadd.rect(0, 0, 100, 100); |
@@ -8,2 +8,6 @@ describe('Path constructors.', | ||
var path = new Path2D(); | ||
if (path.ops_ == undefined) { | ||
// Don't bother testing a native Path2D impl. | ||
return | ||
} | ||
path.rect(0, 0, 100, 100); | ||
@@ -26,2 +30,6 @@ assert.equal(path.ops_[0].type, 'rect', 'Test the test.'); | ||
var path = new Path2D(); | ||
if (path.ops_ == undefined) { | ||
// Don't bother testing a native Path2D impl. | ||
return | ||
} | ||
path.rect(0, 1, 2, 3); | ||
@@ -28,0 +36,0 @@ assert.equal(path.ops_[0].type, 'rect'); |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
175380
1.96%21
5%4801
1.59%