Science, Tech, Math › Computer Science Learn How to Rotate Graphics in SVG Using the rotate function in scalable vector graphics Share Flipboard Email Print mfto / Getty Images Science, Tech, Math PHP Programming Perl Python Java Programming Javascript Programming Delphi Programming C & C++ Programming Ruby Programming Visual Basic View More By Darla Ferrara Darla Ferrara Full-time writer and ghostwriter covering a range of topics including marketing, healthcare, and technology. Learn about our Editorial Process Updated on February 16, 2020 The rotate function in SVG (Scalable Vector Graphics) allows you to specify an angle to which you want to rotate a given image. It works to turn the image in either direction. The World Wide Web Consortium (W3C) defines SVG as "a language based on XML for describing two-dimensional vector and mixed vector/raster graphics. SVG content is stylable, scalable to different display resolutions, and can be viewed stand-alone, mixed with HTML content, or embedded using XML namespaces within other XML languages. SVG also supports dynamic changes; script can be used to create interactive documents, and animations can be performed using declarative animation features or by using script." About Rotate The rotate function is all about the angle of the graphic. When you design an SVG image, you create a static model that will probably sit at a traditional angle. For example, a square will have two sides along the X-axis and two along the Y-axis. With rotate, you can turn that same square into a diamond. With just that one effect, you have gone from a typical box (a common element on websites) to a diamond, which adds interesting visual variety to a design. Rotate is also part of SVG's animation capacities. For example, a circle can turn constantly as it's displayed. This motion can focus the visitor's experience on key areas or elements in a design. Rotate assumes that one dot in the image will remain fixed. Imagine a piece of paper attached to cardboard with a pushpin; the pin location is the fixed spot. If you grab an edge of the paper and rotate it, the pushpin doesn't move, but the rectangle turns. This is how the rotate function works. Rotate Syntax To use rotate, specify the angle of the turn and the coordinates of the fixed area: transform="rotate(45,100,100)" In this code, the angle of rotation is 45 degrees. The center point comes next; in this example, its coordinates are 100 on the x-axis and 100 on the y-axis. If you don't enter center position coordinates, they will default to 0,0. In the example below, the angle is still 45 degrees, but the center point has not been established; therefore, it will default to 0,0. transform="rotate(45)" By default, the angle goes toward the right-hand side of the graph. To rotate the shape in the opposite direction, you use a minus sign to specify a negative value: transform="rotate(-45)" A 45-degree rotation is a quarter-turn, given that the angles are based on a 360-degree circle. If you list the revolution as 360, the image would not change because you'd be flipping it in a full circle. In this way, rotate gives you total control over the angles of your images. Cite this Article Format mla apa chicago Your Citation Ferrara, Darla. "Learn How to Rotate Graphics in SVG." ThoughtCo, Dec. 6, 2021, thoughtco.com/how-to-rotate-in-svg-3469819. Ferrara, Darla. (2021, December 6). Learn How to Rotate Graphics in SVG. Retrieved from https://www.thoughtco.com/how-to-rotate-in-svg-3469819 Ferrara, Darla. "Learn How to Rotate Graphics in SVG." ThoughtCo. https://www.thoughtco.com/how-to-rotate-in-svg-3469819 (accessed March 21, 2023). copy citation