Skip to content

Commit

Permalink
Add 'dotSize' option.
Browse files Browse the repository at this point in the history
It can take either a number or a function that returns a number.
By default it returns (minWidth + maxWidth) / 2.
  • Loading branch information
szimek committed Sep 15, 2013
1 parent 739920c commit 55e57dc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
13 changes: 9 additions & 4 deletions signature_pad.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ var SignaturePad = (function (document) {
this.velocityFilterWeight = opts.velocityFilterWeight || 0.7;
this.minWidth = opts.minWidth || 0.5;
this.maxWidth = opts.maxWidth || 2.5;
this.dotSize = opts.dotSize || function () {
return (this.minWidth + this.maxWidth) / 2;
};
this.color = opts.color || "black";

this._canvas = canvas;
Expand Down Expand Up @@ -57,11 +60,12 @@ var SignaturePad = (function (document) {

var canDrawCurve = self.points.length > 2,
point = self.points[0],
ctx = self._ctx;
ctx = self._ctx,
dotSize = typeof(self.dotSize) === "function" ? self.dotSize.call(self) : self.dotSize;

if (!canDrawCurve && point) {
ctx.beginPath();
self._drawPoint(point.x, point.y, self.minWidth);
self._drawPoint(point.x, point.y, dotSize);
ctx.closePath();
ctx.fill();
}
Expand Down Expand Up @@ -90,11 +94,12 @@ var SignaturePad = (function (document) {
var wasCanvasTouched = event.target === self._canvas,
canDrawCurve = self.points.length > 2,
point = self.points[0],
ctx = self._ctx;
ctx = self._ctx,
dotSize = typeof(self.dotSize) === "function" ? self.dotSize.call(self) : self.dotSize;

if (wasCanvasTouched && !canDrawCurve && point) {
ctx.beginPath();
self._drawPoint(point.x, point.y, self.minWidth);
self._drawPoint(point.x, point.y, dotSize);
ctx.closePath();
ctx.fill();
}
Expand Down
2 changes: 1 addition & 1 deletion signature_pad.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 55e57dc

Please sign in to comment.