files/en-us/web/api/svgtransform/setrotate/index.md
{{APIRef("SVG")}}
The setRotate() method of the {{domxref("SVGTransform")}} interface sets the transform type to SVG_TRANSFORM_ROTATE, with parameter angle defining the rotation angle and parameters cx and cy defining the optional center of rotation.
setRotate(angle, cx, cy)
angle
cx {{optional_inline}}
0.cy {{optional_inline}}
0.None ({{jsxref('undefined')}}).
NoModificationAllowedError {{domxref("DOMException")}}
// Select an SVG element and create a transform object
const svgElement = document.querySelector("svg");
const transform = svgElement.createSVGTransform();
// Set a rotation of 45 degrees
transform.setRotate(45, 0, 0);
// Output the rotation angle
console.log(`Rotation Angle: ${transform.angle}`); // Output: 45
{{Specifications}}
{{Compat}}