With SVG, you can draw most basic shapes; moreover, they are vector graphic, that means, you can zoom in or zoom out the shapes without distortion. SVG is the acronym of scalable vector graphics. It’s defined with XML format. In the examples below, stroke and fill can be color name, RGB, or six digit hex value. For example, stroke=”blue”, or stroke=”RGB(0,0,255)”, or stroke=”#0000ff” has the same effect.
SVG rectangle
In the tag rect, x, and y are the left corner of the rectangle. If you don’t specify a fill-opacity, its default value would be 1.0, that is totally opaque.
Source Code Box: SVG rectangle | Browser: IE9+,Firefox,Chrome
SVG circle
In the tag circle, cx(center x cordinate), and cy(center y coordinate) are the center coordinates of the circle. r is the radius of the circle. Since we didn’t specify a fill-opacity, its default value would be 1.0, that is totally opaque.
Source Code Box: SVG circle
SVG ellipse
In the tag ellipse, cx(center x-axis coordinate), and cy(center y-axis coordinate) are the center coordinates of the ellipse. rx is the x-axis radius. ry is the y-axis radius.
Source Code Box: SVG ellipse
SVG line
In the tag line, x1,y1 are the starting point coordinates; and x2,y2 are the ending point coordinates.
Source Code Box: SVG line
SVG polygon
You can draw a multiple-sided closed shape(at least three sides) with the tag polygon. Each side is a straigh line. In the tag polygon, the x and y coordinates of different points are separated with space.
Source Code Box: SVG polygon
SVG polyline
Polyline is quite similiar to polygon, except it is not a closed shape. Compare this with last example output, you will see that easily.
Source Code Box: SVG polyline
SVG path
A path passes through many points. Adjacent points can be connected by a strait line or a curve. In the tag path, M20 10 means moving to point(20,10). Q100 20 190 170 means a curve connecting point(20,10), point(100,20), and point(190,170). L123 237 means a line from point(190,170) to point(123,237).
Source Code Box: SVG path
SVG text
You can specify text coordinates, color and font size.