Menu
SVG Code to Create a Rectangle and Text and Translate as a Group

Hello!
<svg width="200" height="180" version="1.1" xmlns="http://www.w3.org/2000/svg">
<g transform="translate(50 50)">
   <rect x="0" y="0" width="110" height="70" stroke="#000" fill="#4cff00"></rect>
   <text x="5" y="50" font-family="Verdana" font-size="35">
       Hello!
   </text>
</g>
</svg>

This example shows how to create a rectangle and the text "Hello!". The rectangle is positioned at coordinates x=0 y=0, the upper-right corner of the svg element. The text is positioned at coordinates x=5 y=50. Both elements are contained within a group. To the group tag we add a transform. The transform is translate(50 50). The syntax of the translate transform is shown below.

transform="translate(x y)"

The translate transform takes two parameters, the x value and y value. These value are the amount to move the element along the x axis and the y axis. In the next example, how to group the rectangle and the text elements, and then translate the group, which gives the same result.


Learn more at amazon.com

More Graphics Design Tips:
• Coding Color for the Web
• Inkscape Circles, Ellipses, and Arcs Drawing Tutorial
• Introduction to X3D (Extensible 3D)
• Stop Motion Animation: Nine Creative and Easy Techniques
• How to Make a Meme
• Find Free Stock Photos You'll Actually Want to Use For Your Website or Blog
• How to Make a Simple Video
• How to Create a Game App
• How to Create a Product Box in Photoshop
• Basic Inkscape Vector Drawing