KRouane
KRouane

Reputation: 927

SVG and Javascript - Creating a SVGPoint - TypeError: Illegal constructor

I'm trying to create an SVG polygon from with Javascript.

When I try to creating an SVGPoint with this Javascript code:

var p = new SVGPoint();

I'm getting the following message: - TypeError: Illegal constructor

Upvotes: 8

Views: 9130

Answers (2)

seriyPS
seriyPS

Reputation: 7112

Also you can try to use Raphaël javascript library that implement alternative SVG API and can emulate SVG in InternetExplorer 6+: http://raphaeljs.com/

Upvotes: -3

Nick Craver
Nick Craver

Reputation: 630627

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

var p = svgRoot.createSVGPoint();

SVGPoint (the interface itself) has no constructor, that's why you're getting an error currently.

Upvotes: 13

Related Questions