diff options
| author | Jules Laplace <jules@okfoc.us> | 2014-11-18 18:41:32 -0500 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2014-11-18 18:41:32 -0500 |
| commit | 1f86b57c3036a137120e7e0568eec33c1f6a98f1 (patch) | |
| tree | 1afa092f72b24dc1190e178f18999b7677ac1c14 /assets/test/lasso/index.html | |
| parent | 4c5fddd39465514de192c1a678a24137271a3b40 (diff) | |
more brush stuff
Diffstat (limited to 'assets/test/lasso/index.html')
| -rw-r--r-- | assets/test/lasso/index.html | 88 |
1 files changed, 0 insertions, 88 deletions
diff --git a/assets/test/lasso/index.html b/assets/test/lasso/index.html deleted file mode 100644 index 62a9744..0000000 --- a/assets/test/lasso/index.html +++ /dev/null @@ -1,88 +0,0 @@ -<style> -body,html{margin:0;padding:0;} -#hud { position: absolute; top: 0; left: 0; pointer-events: none; } -</style> -<canvas id="canvas"></canvas> -<div id="hud"></div> - -<script src="/assets/javascripts/vendor/bower_components/jquery/dist/jquery.min.js"></script> -<script src="/assets/javascripts/vendor/bower_components/lodash/dist/lodash.min.js"></script> -<script src="/assets/javascripts/vendor/canvasutilities.js"></script> -<script src="/assets/javascripts/vendor/tube.js"></script> -<script src="/assets/javascripts/math/util.js"></script> -<script src="/assets/javascripts/math/point.js"></script> -<script src="/assets/javascripts/math/vec2.js"></script> -<script src="/assets/javascripts/util/mouse.js"></script> -<script src="/assets/javascripts/util/uid.js"></script> -<script> - -var ctx = canvas.getContext('2d') -var w = canvas.width = window.innerWidth -var h = canvas.height = window.innerHeight - -var placing = false -var points = [] - -var mymouse = new mouse({ - el: canvas, - down: function(e, cursor){ - // compare to initial point - if (placing) { - if (points.length > 2 && points[0].distanceTo(cursor.a) < 3) { - points.push(points[0].clone()) - placing = false - } - else { - points.push( cursor.a ) - } - } - else { - placing = true - points.length = 0 - points.push( cursor.a ) - } - }, - move: function(e, cursor){ - if (placing && points.length > 2 && points[0].distanceTo(cursor.a) < 3 ) { - document.body.style.cursor = "pointer" - } - else { - document.body.style.cursor = "crosshair" - } - }, - drag: function(e, cursor){ - }, - up: function(e, cursor, new_cursor){ - }, -}) - -function draw (time) { - ctx.fillStyle = "#fff" - ctx.fillRect(0,0,w,h) - - if (points.length == 1) { - ctx.fillStyle = "#000" - ctx.fillRect(points[0].x, points[0].y, 1, 1) - } - if (points.length > 1) { - ctx.fillStyle = "#000" - ctx.strokeStyle = "#000" - ctx.beginPath() - ctx.moveTo(points[0].x, points[0].y) - points.forEach(function(point, i){ - i && ctx.lineTo(point.x, point.y) - }) - if (placing) { - ctx.stroke() - } - else { - ctx.fill() - } - } -} -function animate(time){ - requestAnimationFrame(animate) - draw(time) -} -animate() -</script> |
