Fabric.js: Object scaleX / scaleY get rounded by canvas.toJSON()

Created on 17 Dec 2013  路  2Comments  路  Source: fabricjs/fabric.js

canvas.toJSON() rounds object.scaleX and object.scaleY to two decimals (and maybe other properties as well). This is really annoying if you try to connect/snap multiple objects. On canvas they connect but after exporting to (and importing from) JSON they are out of place (shifted).

DEMO: http://vps.matthijskuiper.nl/test/2/

This demo includes a workaround as well (.toJSON(['scaleX', 'scaleY'])).
But I think toJSON shouldn't be rounding values hence this issue.

Most helpful comment

You can increase the number of decimals to round:

fabric.Object.NUM_FRACTION_DIGITS = 10;

All 2 comments

You can increase the number of decimals to round:

fabric.Object.NUM_FRACTION_DIGITS = 10;

Wow thanks, wish I found out about this sooner...

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lyzs90 picture lyzs90  路  3Comments

f987002856 picture f987002856  路  3Comments

semiadam picture semiadam  路  3Comments

eddieyangtx picture eddieyangtx  路  5Comments

amancqlsys picture amancqlsys  路  5Comments