Skip to content
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.

Method

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.

Affected attributes

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.

Usage note

I recommend applying transforms before calling setDecimalPlaces() to avoid rounding errors.

Clone this wiki locally