blue bar

Home  |  Resources SiteMap  

blue bar
    Basic Drawing > Path > Line & Shape

Print Version       Previous       Next       

Line and Shape

Here are the basic path commands. (Upper case for absolute positioning, lower case relative positioning).

Command

Meaning

Parameters

M/m
(moveTo)

Establish origin at point specified

Two parameters (x,y) giving current position

L/l
(lineTo)

Straight line path from current position to point specified

Two parameters (x,y) giving position of the line end point which becomes the current position.

H/h
(horizontalLineTo)

Horizontal line path from current position to point specified

Single parameter giving X-coordinate of the line end point.
The Y-coordinate is the same as that of the previous current position. The new point becomes the current position.

V/v
(verticalLineTo)

Vertical line path from current position to point specified

Single parameter giving Y-coordinate of the line end point.
The X-coordinate is the same as that of the previous current position. The new point becomes the current position.

Z/z
(closePath)

Straight line back to original point

No parameters.

Note: If the path being specified consists of many short paths, it may well be more efficient to define the path as relative positions from the previous current position. Each command has a lower case equivalent which defines the coordinate values as relative to the previous current position.

Code Example

SVG Image

<?xml version="1.0" standalone="no"?>

Right-click on the image to open the SVG viewer pop-up menu. Click 'view SVG' to display the image in a new, full window to zoom & pan the image.  (SVG Viewer Tips)


<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">

<svg width="150" height="250" xmlns="http://www.w3.org/2000/svg" version="1.1">

<!-- Points and Lines -->
<path d="M15,5 L50,65 H70 V30 h10 L100 70 l-20 16"
style="fill:none; stroke:blue"/>

<!-- A traingle -->
<path d="M20 100 L60 100 L40 140 Z" style="fill:none; stroke:red"/>

<!-- Areas -->
<path d="M10 160 L30 200 L100 160 L70 200 Z"
style="fill:none; stroke:green"/>

</svg>

Previous       Next     

   
 

About the Tutorial

 

SVG Overview

 

SVG Concepts

 

Basic Drawing

  Getting Started
  Graphical Objects
 

Basic Shapes

 

Path

    About Path
    Line & Shape
    Cubic Curve
    Quadratic Curve
    Elliptical Curve
  Text
  Quiz
 

Painting & Effects

 

Dynamic SVG