Skip to content

Commit

Permalink
Release 2.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
szimek committed Jun 11, 2017
1 parent faf4cf7 commit b4cd1d9
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 13 deletions.
7 changes: 5 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
## Changelog

### master
### 2.2.0
#### Bug Fixes
* Export to SVG with correct pen colors. ([DynamoEffects](https://github.com/DynamoEffects) in [#260](https://github.com/szimek/signature_pad/pull/260))

* Allow custom ratio/width/height when loading data URL onto canvas
#### Features
* Allow custom ratio/width/height when loading data URL onto canvas. ([halo](https://github.com/halo) in [#253](https://github.com/szimek/signature_pad/pull/253))

### 2.1.1
* Fixed a bug where default value was applied for throttle when throttle was set to 0. ([mkrause](https://github.com/mkrause) in [#247](https://github.com/szimek/signature_pad/pull/247))
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Signature Pad [![npm](https://d25lcipzij17d.cloudfront.net/badge.svg?id=js&type=6&v=2.1.1&x2=0)](https://www.npmjs.com/package/signature_pad) [![Code Climate](https://codeclimate.com/github/szimek/signature_pad.png)](https://codeclimate.com/github/szimek/signature_pad)
# Signature Pad [![npm](https://d25lcipzij17d.cloudfront.net/badge.svg?id=js&type=6&v=2.2.0&x2=0)](https://www.npmjs.com/package/signature_pad) [![Code Climate](https://codeclimate.com/github/szimek/signature_pad.png)](https://codeclimate.com/github/szimek/signature_pad)


Signature Pad is a JavaScript library for drawing smooth signatures. It's HTML5 canvas based and uses variable width Bézier curve interpolation based on [Smoother Signatures](http://corner.squareup.com/2012/07/smoother-signatures.html) post by [Square](https://squareup.com).
Expand Down
22 changes: 13 additions & 9 deletions example/js/signature_pad.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Signature Pad v2.1.1
* Signature Pad v2.2.0
* https://github.com/szimek/signature_pad
*
* Copyright 2017 Szymon Nowak
Expand Down Expand Up @@ -199,10 +199,12 @@ SignaturePad.prototype.clear = function () {
SignaturePad.prototype.fromDataURL = function (dataUrl) {
var _this = this;

var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};

var image = new Image();
var ratio = window.devicePixelRatio || 1;
var width = this._canvas.width / ratio;
var height = this._canvas.height / ratio;
var ratio = options.ratio || window.devicePixelRatio || 1;
var width = options.width || this._canvas.width / ratio;
var height = options.height || this._canvas.height / ratio;

this._reset();
image.src = dataUrl;
Expand Down Expand Up @@ -274,7 +276,8 @@ SignaturePad.prototype._strokeUpdate = function (event) {
this._data[this._data.length - 1].push({
x: point.x,
y: point.y,
time: point.time
time: point.time,
color: this.penColor
});
};

Expand Down Expand Up @@ -459,6 +462,7 @@ SignaturePad.prototype._fromData = function (pointGroups, drawCurve, drawDot) {
for (var j = 0; j < group.length; j += 1) {
var rawPoint = group[j];
var point = new Point(rawPoint.x, rawPoint.y, rawPoint.time);
var color = rawPoint.color;

if (j === 0) {
// First point in a group. Nothing to draw yet.
Expand All @@ -471,7 +475,7 @@ SignaturePad.prototype._fromData = function (pointGroups, drawCurve, drawDot) {
widths = _addPoint2.widths;

if (curve && widths) {
drawCurve(curve, widths);
drawCurve(curve, widths, color);
}
} else {
// Last point in a group. Do nothing.
Expand Down Expand Up @@ -500,7 +504,7 @@ SignaturePad.prototype._toSVG = function () {
svg.setAttributeNS(null, 'width', canvas.width);
svg.setAttributeNS(null, 'height', canvas.height);

this._fromData(pointGroups, function (curve, widths) {
this._fromData(pointGroups, function (curve, widths, color) {
var path = document.createElement('path');

// Need to check curve for NaN values, these pop up when drawing
Expand All @@ -511,7 +515,7 @@ SignaturePad.prototype._toSVG = function () {

path.setAttribute('d', attr);
path.setAttribute('stroke-width', (widths.end * 2.25).toFixed(3));
path.setAttribute('stroke', _this2.penColor);
path.setAttribute('stroke', color);
path.setAttribute('fill', 'none');
path.setAttribute('stroke-linecap', 'round');

Expand All @@ -523,7 +527,7 @@ SignaturePad.prototype._toSVG = function () {
circle.setAttribute('r', dotSize);
circle.setAttribute('cx', rawPoint.x);
circle.setAttribute('cy', rawPoint.y);
circle.setAttribute('fill', _this2.penColor);
circle.setAttribute('fill', rawPoint.color);

svg.appendChild(circle);
});
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "signature_pad",
"description": "Library for drawing smooth signatures.",
"version": "2.1.1",
"version": "2.2.0",
"homepage": "https://github.com/szimek/signature_pad",
"author": {
"name": "Szymon Nowak",
Expand Down

0 comments on commit b4cd1d9

Please sign in to comment.