Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 711
KRouane Avatar asked Nov 21 '10 18:11

KRouane


1 Answers

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.

like image 73
Nick Craver Avatar answered Sep 22 '22 03:09

Nick Craver