-
Notifications
You must be signed in to change notification settings - Fork 24
Set decimal places
petercollingridge edited this page Feb 1, 2012
·
5 revisions
Coordinates in SVGs are often given to four or more decimal places, which is almost never necessary. In most cases one decimal place is sufficient.
To set the number of decimal places to x, call: svg.setDecimalPlaces(x)
The parameter, x, can be 0 or any positive integer. If a parameter has less than x decimal places, then it will be unchanged.
The attributes currently affected by setDecimalPlaces are:
- x, y, x1, y2, x2, y2
- cx, cy
- r, rx, ry
- width, height
- points
- d
Note that the transform attribute is not currently affected.
I recommend applying transforms before calling setDecimalPlaces() to avoid rounding errors.