SVG and Javascript - Creating SVGPoint - TypeError: Illegal Constructor

I am trying to create an SVG polygon using Javascript.

When I try to create SVGPoint with this Javascript code:

var p = new SVGPoint();

I get the following message: - TypeError: Illegal constructor

+5
source share
2 answers

From your SVG document, you need to call .createSVGPoint()to create a new point (initlaized at 0,0), for example:

var p = svgRoot.createSVGPoint();

SVGPoint (the interface itself) does not have a constructor, so you are currently getting an error.

+11
source

JavaScript Raphaël, SVG API SVG InternetExplorer 6+: http://raphaeljs.com/ p >

-2

All Articles