Wesley Skeen
Wesley Skeen

Reputation: 8285

Explanation on how to draw a straight line in Raphael.js

I would like some help on the path constructor in Raphael. Im not sure how to draw a straight line from one point to another. I have

var line = paper.path(M 100 0 1 0 30 100)

I want to draw a line from point1 (100 0) to point2 (30 100)

Upvotes: 8

Views: 12653

Answers (1)

Kevin Nielsen
Kevin Nielsen

Reputation: 4433

It's very simple:

var line = paper.path( "M100,0 L30,100" );

You can also build your paths out of arrays, which is really useful in some circumstances.

var line = paper.path( ["M", 100, 0, "L", 30, 100 ] );

Upvotes: 17

Related Questions