Created
September 6, 2014 17:08
-
-
Save athap/444978115341727dd368 to your computer and use it in GitHub Desktop.
Draws a line
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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