Skip to content

Commit

Permalink
Add rotateContextAt, resetCanvas, resetTransforms and clearWithTransf…
Browse files Browse the repository at this point in the history
…orms
  • Loading branch information
tillarnold committed Dec 5, 2015
1 parent a1d910d commit 368ff5f
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 5 deletions.
26 changes: 26 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ var methodNames = [
'rotate',
'save',
'scale',
'setTransform',
'stroke',
'strokeRect',
'strokeText',
Expand Down Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
5 changes: 4 additions & 1 deletion test/beefy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

0 comments on commit 368ff5f

Please sign in to comment.