diff --git a/index.js b/index.js index f80a3a2..e92c019 100644 --- a/index.js +++ b/index.js @@ -23,6 +23,7 @@ var methodNames = [ 'rotate', 'save', 'scale', + 'setTransform', 'stroke', 'strokeRect', 'strokeText', @@ -79,6 +80,31 @@ Leinwand.prototype.circle = function cirlce(x, y, r) { return this; }; +Leinwand.prototype.rotateContextAt = function rotateContextAt(x, y, r) { + this.translate(x, y); + this.rotate(r); + this.translate(-1 * x, -1 * y); + return this; +}; + +Leinwand.prototype.resetCanvas = function resetCanvas(){ + this._canvas.width = this._canvas.width; + return this; +}; + +Leinwand.prototype.resetTransforms = function resetTransforms() { + this.setTransform(1, 0, 0, 1, 0, 0); + return this; +}; + +Leinwand.prototype.clearWithTransforms = function clearWithTransforms() { + this.save(); + this.resetTransforms(); + this.clear(); + this.restore(); + return this; +}; + //Getters Leinwand.prototype.getContext = function getContext() { return this._ctx; diff --git a/package.json b/package.json index a385e07..582ec17 100644 --- a/package.json +++ b/package.json @@ -19,11 +19,11 @@ "author": "Till Arnold", "license": "MIT", "devDependencies": { - "jshint": "^2.8.0", - "tape": "^4.2.0", - "istanbul": "~0.3.20", + "jshint": "^2.9.1-rc1", + "tape": "^4.2.2", + "istanbul": "~0.4.1", "coveralls": "~2.11.4", "beefy": "^2.1.5", - "watchify": "^3.4.0" + "watchify": "^3.6.1" } } diff --git a/test/beefy.js b/test/beefy.js index 3f3cbb9..1ba980a 100644 --- a/test/beefy.js +++ b/test/beefy.js @@ -24,4 +24,7 @@ l .fillStyle('blue') .circle(50,50,40) .fill() - .stroke(); + .stroke() + .fillRect(200,200,100,100) + .rotateContextAt(250,250,Math.PI/4) + .fillRect(200,200,100,100);