Skip to content

Instantly share code, notes, and snippets.

@athap
Created September 6, 2014 17:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save athap/444978115341727dd368 to your computer and use it in GitHub Desktop.
Save athap/444978115341727dd368 to your computer and use it in GitHub Desktop.
Draws a line
// Draws a line from one circle(node) to another circle (node)
var Line = function() {
// Takes
// x,y - starting x,y coordinate
// toX, toY - ending x,y coordinate
this.draw = function(x, y, toX, toY, r, ctx) {
var moveToX = x;
var moveToY = y + r;
var lineToX = toX;
var lineToY = toY - r;
ctx.beginPath();
ctx.moveTo(moveToX, moveToY);
ctx.lineTo(lineToX, lineToY);
ctx.stroke();
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment