mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2024-12-29 09:22:22 -05:00
Handle exportSVG({ precision: 0 }) correctly
This commit is contained in:
parent
f1257d83b2
commit
1b129feebf
2 changed files with 10 additions and 1 deletions
|
@ -20,7 +20,7 @@ var Formatter = Base.extend(/** @lends Formatter# */{
|
|||
* @param {Number} [precision=5] the amount of fractional digits
|
||||
*/
|
||||
initialize: function(precision) {
|
||||
this.precision = precision || 5;
|
||||
this.precision = precision == null ? 5 : precision;
|
||||
this.multiplier = Math.pow(10, this.precision);
|
||||
},
|
||||
|
||||
|
|
|
@ -103,3 +103,12 @@ test('Export SVG polyline', function() {
|
|||
}));
|
||||
});
|
||||
|
||||
test('Export SVG path defaults to precision 5', function() {
|
||||
var path = new Path('M0.123456789,1.9l0.8,1.1');
|
||||
equals(path.exportSVG({}).getAttribute('d'), 'M0.12346,1.9l0.8,1.1');
|
||||
});
|
||||
|
||||
test('Export SVG path at precision 0', function() {
|
||||
var path = new Path('M0.123456789,1.9l0.8,1.1');
|
||||
equals(path.exportSVG({ precision: 0 }).getAttribute('d'), 'M0,2l1,1');
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue