Created
December 12, 2014 15:21
-
-
Save garciadelcastillo/b4660a6dc7d364702e20 to your computer and use it in GitHub Desktop.
Sketchpad.js - Point.along
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
<!DOCTYPE html> | |
<meta charset="utf-8"> | |
<html> | |
<head> | |
<link rel="stylesheet" type="text/css" href="styles.css"> | |
</head> | |
<body> | |
<div id="sketchpadDiv"> | |
<canvas id="sketchpadCanvas"></canvas> | |
</div> | |
</body> | |
<script type="text/javascript" src="https://code.jquery.com/jquery-2.1.1.min.js"></script> | |
<script type="text/javascript" src="http://www.garciadelcastillo.es/sketchpad/sketchpad.js"></script> | |
<script type="text/javascript" src="sketch.js"></script> | |
</html> |
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
// Create new instance of Sketchpad in target Canvas | |
var pad = new Sketchpad('sketchpadCanvas'); | |
// Create a Line between two Nodes | |
var A = new pad.Node(160, 200), | |
B = new pad.Node(480, 200), | |
AB = pad.Line.between(A, B); | |
// Create a Point at 3/4 the length of the Line, and use it as center of a Circle | |
var C = pad.Point.along(AB, 0.75), | |
bigCircle = pad.Circle.centerRadius(C, 51); | |
// Create a Point at 1/4 the length of that Circle, and draw another Circle | |
var D = pad.Point.along(bigCircle, 0.25), | |
smallCircle = pad.Circle.centerRadius(D, 26); | |
// Display Tags only on Node elements | |
pad.tagNodes(); |
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
body { | |
margin: 0; | |
padding: 0; | |
} | |
#sketchpadDiv { | |
position: absolute; | |
width: 100%; | |
height: 100%; | |
border: 1px solid #000; | |
-webkit-box-sizing: border-box; | |
-moz-box-sizing: border-box; | |
box-sizing: border-box; | |
} | |
#sketchpadCanvas { | |
position: absolute; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment