Skip to content

Move to

Paul van Dinther edited this page Oct 1, 2022 · 2 revisions

MoveTo instruction must always be used as the first command to start a new path. This will initialize the current point and several global parameters.

Command Parameters Notes
M (x, y)+ Move the current point to the coordinate x,y. Any subsequent coordinate pair(s) are interpreted as parameter(s) for implicit absolute LineTo (L) command(s) (see below).
Formula: Pn = {x, y}
m (dx, dy)+ Move the current point by shifting the last known position of the path by dx along the x-axis and by dy along the y-axis. Any subsequent coordinate pair(s) are interpreted as parameter(s) for implicit relative LineTo (l) command(s) (see below).
Formula: Pn = {xo + dx, yo + dy}

m(x,y) or m([x1,y1,x2,y2,...]) multiple coordinate pairs can be passed to the command module by means of a number list.

The first coordinate pair is always absolute, optional subsequent coordinate pairs are treated as either relative to the first coordinate pair when the command is lowercase otherwise subsequent coordinate pairs are treated as absolute.

Examples

in string format

svgShape("M 1,2 L 7,8 V 2");   //  draws a triangle with start x,y at 1,2
svgShape("m 9,2 6,6 V 2");     //  same triangle as above with start x,y at 9,2

Note in the second example that subsequent points are added relative to the start point because m is lowercase

in command format

M(1,2) L(7,8) V(2);
m([9,2,6,6]) V(2);

Note in the second example that a list is used to pass the 4 values while in the first example x and y value are passed as separate numbers.

Clone this wiki locally