How to create an SVG Matrix without an SVG element in the DOM

dom, javascript, svg

Solution

How about

var matrix = document.createElementNS("http://www.w3.org/2000/svg", "svg").createSVGMatrix();

Problem

I have been accessing the SVGMatrix prototype to use its power for matrix transformations. These transformations are not necessarily related to any SVG element ``` var svgElement = $('svg')[0]; var svgMatrix = svgElement.createSVGMatrix() Object.create(svgMatrix.__proto__) ``` Essentially I want to be able to create a svgMatrix as in line two without first relying on a svg element in the DOM as in line 1.

Original source