Added rect + circle methods

This commit is contained in:
Luis Leiva 2017-12-17 22:42:05 +01:00
parent 90b0cab450
commit 861de16b91
1 changed files with 44 additions and 0 deletions

View File

@ -290,6 +290,28 @@
return this;
},
/**
* Draws a filled+stroked rectangle.
* @param {number} x - Horizontal coordinate.
* @param {number} y - Vertical coordinate.
* @param {number} width - Rectangle width.
* @param {number} height - Rectangle height.
* @return jSketch
* @memberof jSketch
*/
rect: function(x, y, width, height) {
var args = [].slice.call(arguments);
this.context.beginPath();
this.context.fillRect.apply(this.context, args);
this.context.strokeRect.apply(this.context, args);
this.context.closePath();
this.callStack.push({ method: 'fillRect', args: args });
this.callStack.push({ method: 'strokeRect', args: args });
return this;
},
/**
* Draws a stroke-only circle.
* @param {number} x - Horizontal coordinate.
@ -330,6 +352,28 @@
return this;
},
/**
* Draws a filled+stroked circle.
* @param {number} x - Horizontal coordinate.
* @param {number} y - Vertical coordinate.
* @param {number} radius - Circle radius.
* @return jSketch
* @memberof jSketch
*/
circle: function(x, y, radius) {
var args = [x, y, radius, 0, 2*Math.PI, false];
this.context.beginPath();
this.context.arc.apply(this.context, args);
this.context.fill();
this.context.stroke();
this.context.closePath();
this.callStack.push({ method: 'fillCircle', args: args });
this.callStack.push({ method: 'strokeCircle', args: args });
return this;
},
/**
* Experimental.
* @ignore