summaryrefslogtreecommitdiff
path: root/assets/test/brush/index.html
diff options
context:
space:
mode:
authorJules Laplace <jules@okfoc.us>2014-11-18 15:36:17 -0500
committerJules Laplace <jules@okfoc.us>2014-11-18 15:36:17 -0500
commit24047fd4fea0f91aa66023434abc0030cf8dfb90 (patch)
tree7a2972fd42f8f7abeb6b44dfb1b283e2d7a5bc7b /assets/test/brush/index.html
parent551dabc2e9f0202848fe000084fc4283272faed3 (diff)
making the point/vec2 naming more normal
Diffstat (limited to 'assets/test/brush/index.html')
-rw-r--r--assets/test/brush/index.html34
1 files changed, 17 insertions, 17 deletions
diff --git a/assets/test/brush/index.html b/assets/test/brush/index.html
index 4bdaf98..cd31198 100644
--- a/assets/test/brush/index.html
+++ b/assets/test/brush/index.html
@@ -33,23 +33,23 @@ var mymouse = new mouse({
el: canvas,
down: function(e, cursor){
drawing = true
- lastPoint.a = cursor.x.a
- lastPoint.b = cursor.y.a
+ lastPoint.x = cursor.a.x
+ lastPoint.y = cursor.a.y
// mask.clearRect(0,0,w,h)
// imagedata = ctx.getImageData( 0, 0, canvas.width, canvas.height )
// data = imagedata.data
},
drag: function(e, cursor){
- newPoint.a = cursor.x.b
- newPoint.b = cursor.y.b
+ newPoint.x = cursor.b.x
+ newPoint.y = cursor.b.y
drawLine(lastPoint, newPoint)
- lastPoint.a = newPoint.a
- lastPoint.b = newPoint.b
+ lastPoint.x = newPoint.x
+ lastPoint.y = newPoint.y
},
up: function(e, cursor, new_cursor){
drawing = false
- drawLine({ a: cursor.x.a, b: cursor.y.a }, { a: cursor.x.b, b: cursor.y.b })
+ drawLine(cursor.a, cursor.b)
console.log("hi")
},
})
@@ -57,11 +57,11 @@ var mymouse = new mouse({
function drawLine (u, v) {
var radius = 10
- var xmin = Math.min(u.a, v.a)
- var ymin = Math.min(u.b, v.b)
+ var xmin = Math.min(u.x, v.x)
+ var ymin = Math.min(u.y, v.y)
- var w = scratch.width = abs(u.a - v.a) + radius*2
- var h = scratch.height = abs(u.b - v.b) + radius*2
+ var w = scratch.width = abs(u.x - v.x) + radius*2
+ var h = scratch.height = abs(u.y - v.y) + radius*2
var p = new point (0,0)
var radius2 = radius * radius
@@ -74,8 +74,8 @@ function drawLine (u, v) {
for (j = 0; j < h; j++) {
t = (j * w + i) * 4
- p.a = xmin + i - radius
- p.b = ymin + j - radius
+ p.x = xmin + i - radius
+ p.y = ymin + j - radius
dist = distToSegmentSquared( p, u, v )
@@ -96,14 +96,14 @@ drawLine( new point( 100, 100 ), new point( 100, 400 ) )
// drawLine( new point( 100, 100 ), new point( 400, 400 ) )
function sqr(x) { return x * x }
-function dist2(v, w) { return sqr(v.a - w.a) + sqr(v.b - w.b) }
+function dist2(v, w) { return sqr(v.x - w.x) + sqr(v.y - w.y) }
function distToSegmentSquared (p, v, w) {
var l2 = dist2(v, w)
- var t = ((p.a - v.a) * (w.a - v.a) + (p.b - v.b) * (w.b - v.b)) / l2
+ var t = ((p.x - v.x) * (w.x - v.x) + (p.y - v.y) * (w.y - v.y)) / l2
if (t < 0) return dist2(p, v)
if (t > 1) return dist2(p, w)
- return dist2(p, { a: v.a + t * (w.a - v.a),
- b: v.b + t * (w.b - v.b) })
+ return dist2(p, { x: v.x + t * (w.x - v.x),
+ y: v.y + t * (w.y - v.y) })
}