Menu
SVG Example Code to Scale Elements

<svg width="340" height="350" version="1.1" xmlns="http://www.w3.org/2000/svg" style="border-style:solid;">
   <rect x="50" y="50" width="100" height="100" stroke="#000" fill="red" />
   <rect x="50" y="50" width="100" height="100" stroke="#000" fill="green" transform="scale(0.5)" />
   <rect x="50" y="50" width="100" height="100" stroke="#000" fill="blue" transform="scale(2)" />

   <rect x="50" y="50" width="100" height="100" stroke="#000" fill="yellow" transform="scale(0.5 2)" />
</svg>

The scale transform changes the size of an element. The syntax of the scale transform is shown below.

transform="scale(x, y)"

scale takes two parameters, the factor by which to scale the element on the x axis, and the factor by which to scale the element on the y axis. If one parameter is omitted, then both axis will be scaled by the single factor provided. The factors are interpreted as the ratio of the transformed dimension to the original. For example, 0.5 shrinks the axis by 50%.

In the example shown above, all squares have the same x and y axis locations and the same width and height dimensions. The red square has no transform applied. The green square uses the scale transform with a single parameter of 0.5. Note that not only does the scale parameter scale the element, it also scales the position of the element. In other words, the green square can be considered to be on its own layer with axis scaled to 0.5.

The blue square uses the scale transform with a single parameter of 2. Note again that the scale parameter scales the position of the element. The yellow square uses the scale transform with a parameter of 0.5 for the x axis and 2 for the y axis. Note that not only is the location of the element scaled, but the width's of the borders are also scaled.


Learn more at amazon.com

More Graphics Design Tips:
• Pencil Free Open Source Cartoon Animation Drawing Program
• The Browser Safe Palette
• Example Code for X3Dom Basic Primitive Shapes: Box, Sphere, Cylinder, Cone, and Torus
• Introduction to X3D (Extensible 3D)
• Selecting Vertices Edges and Faces in Blender
• Inkscape - How to Join Two Segments at Endnodes
• SVG Example Code to Rotate Elements
• Inkscape Document Properties
• Inkscape Basic Fill
• Getting Started with Blender