diff --git a/src/basic/Matrix.js b/src/basic/Matrix.js index 89e4e13b..7b79dd88 100644 --- a/src/basic/Matrix.js +++ b/src/basic/Matrix.js @@ -193,9 +193,11 @@ var Matrix = this.Matrix = Base.extend({ * @return {string} A string representation of this transform. */ toString: function() { - return '[[' - + [this._m00, this._m01, this._m02].join(', ') + '], [' - + [this._m10, this._m11, this._m12].join(', ') + ']]'; + var format = Base.formatNumber; + return '[[' + [format(this._m00), format(this._m01), + format(this._m02)].join(', ') + '], [' + + [format(this._m10), format(this._m11), + format(this._m12)].join(', ') + ']]'; }, /** diff --git a/src/basic/Point.js b/src/basic/Point.js index 13f827f7..98b04794 100644 --- a/src/basic/Point.js +++ b/src/basic/Point.js @@ -454,7 +454,8 @@ var Point = this.Point = Base.extend({ }, toString: function() { - return '{ x: ' + this.x + ', y: ' + this.y + ' }'; + var format = Base.formatNumber; + return '{ x: ' + format(this.x) + ', y: ' + format(this.y) + ' }'; }, statics: { diff --git a/src/basic/Rectangle.js b/src/basic/Rectangle.js index ba4a561e..4c48771c 100644 --- a/src/basic/Rectangle.js +++ b/src/basic/Rectangle.js @@ -221,10 +221,11 @@ var Rectangle = this.Rectangle = Base.extend({ }, toString: function() { - return '{ x: ' + this.x - + ', y: ' + this.y - + ', width: ' + this.width - + ', height: ' + this.height + var format = Base.formatNumber; + return '{ x: ' + format(this.x) + + ', y: ' + format(this.y) + + ', width: ' + format(this.width) + + ', height: ' + format(this.height) + ' }'; }, diff --git a/src/basic/Size.js b/src/basic/Size.js index 1785d971..471f53b5 100644 --- a/src/basic/Size.js +++ b/src/basic/Size.js @@ -86,7 +86,9 @@ var Size = this.Size = Base.extend({ }, toString: function() { - return '{ x: ' + this.width + ', y: ' + this.height + ' }'; + var format = Base.formatNumber; + return '{ x: ' + format(this.width) + + ', y: ' + format(this.height) + ' }'; }, statics: { diff --git a/src/color/Color.js b/src/color/Color.js index 4d551037..30623def 100644 --- a/src/color/Color.js +++ b/src/color/Color.js @@ -173,13 +173,14 @@ var Color = this.Color = Base.extend(new function() { }, toString: function() { - var parts = []; + var parts = [], + format = Base.formatNumber; for (var i = 0, l = this._components.length; i < l; i++) { - var component = this._components[i]; - var value = this['_' + component]; + var component = this._components[i], + value = this['_' + component]; if (component === 'alpha' && value == null) value = 1; - parts.push(component + ': ' + value); + parts.push(component + ': ' + format(value)); } return '{ ' + parts.join(', ') + ' }'; }, diff --git a/src/paper.js b/src/paper.js index 9ffecf0c..953236ba 100644 --- a/src/paper.js +++ b/src/paper.js @@ -83,6 +83,10 @@ Base.inject({ return str.replace(/\b[a-z]/g, function(match) { return match.toUpperCase(); }); + }, + + formatNumber: function(num) { + return (Math.round(num * 100000) / 100000).toString(); } }); diff --git a/src/path/CurveLocation.js b/src/path/CurveLocation.js index 54d8f5fa..ca7f3349 100644 --- a/src/path/CurveLocation.js +++ b/src/path/CurveLocation.js @@ -129,8 +129,8 @@ CurveLocation = Base.extend({ }, toString: function() { - var parts = []; - var point = this.getPoint(); + var parts = [], + point = this.getPoint(); if (point) parts.push('point: ' + point); var index = this.getIndex(); @@ -138,7 +138,7 @@ CurveLocation = Base.extend({ parts.push('index: ' + index); var parameter = this.getParameter(); if (parameter != null) - parts.push('parameter: ' + parameter); + parts.push('parameter: ' + Base.formatNumber(parameter)); return '{ ' + parts.join(', ') + ' }'; } }); diff --git a/src/tool/ToolEvent.js b/src/tool/ToolEvent.js index 138aef5e..ee81bac2 100644 --- a/src/tool/ToolEvent.js +++ b/src/tool/ToolEvent.js @@ -42,10 +42,10 @@ var ToolEvent = this.ToolEvent = Base.extend({ toString: function() { return '{ type: ' + this.type - + ', point: ' + this.point - + ', count: ' + this.count - + ', modifiers: ' + this.modifiers - + ' }'; + + ', point: ' + this.point + + ', count: ' + this.count + + ', modifiers: ' + this.modifiers + + ' }'; }, /**