Objective: to practice a practical application of xy coordinates by manipulating an SVG web page.
In this exercise we will use a web page language called Scalable Vector Graphics (SVG) to explore a practical use of an xy coordinate grid. Using SVG, shapes can be drawn at a location specified by x and y coordinates. We will learn to position circles in this exercise. We will use the gEdit text editor and the FireFox browser to work with SVG.
Note: On the computer screen the x coordinates increase from left to right just as they do in mathematics. The y coordinate, however, increases from top to bottom on the computer screen, the opposite direction from mathematics.
You will start with five circles in a row in the upper left corner of a box. The box is 400 wide by 400 high. You will be changing the x and y coordinates to move the circles into new formations.
SVG web page code is slightly more complicated than HTML web page code. You will copy code from an SVG page to start.
Your first task will be to arrange the circles in a straight line across the middle of the square. The arrangement is seen below in illustration one.
To move the circles you will have to change the locations of the centers of the circles.
In SVG the circle command is
<circle cx="20" cy="15" r="10" />
cx is the x coordinate of the center of the circle.
cy is the y coordinate of the center of the circle.
r is the radius of the circle.
Which coordinate controls the horizontal position of the circles? Which coordinate controls the vertical position of the circles?
Then create each of the following diagrams.
To make more circles, copy and paste additional circle command lines.
Changing the colors of the circles. You can use the hexadecimal color commands to change the circle colors. Add the fill attribute to the circle element with the hexadecimal color values you learned earlier in the week as seen below.
<?xml version="1.0" encoding="utf-8"?> <svg xmlns="http://www.w3.org/2000/svg" width="400px" height="400px"> <title>SVG scratch pad</title> <g stroke="black" stroke-width="3px" fill="none"> <desc>Border</desc> <rect x="0" y="0" width="400" height="400" /> </g> <g stroke="black" stroke-width="2px" fill="deepskyblue" > <desc>Circles</desc> <circle cx="20" cy="15" r="10" fill="#F00" /> <circle cx="40" cy="15" r="10" fill="#F80" /> <circle cx="60" cy="15" r="10" fill="#FF0" /> <circle cx="80" cy="15" r="10" fill="#8F0" /> <circle cx="100" cy="15" r="10" fill="#0F0" /> </g> </svg>