Distance between two canvas co-ordinates in javascript -
i'm acquainted basic math , know equations, when try implement them in canvas fail.
here's relevant code:
function distance(one,two){ var a, b if(one[0] > one[1]){ = one[1] - one[0] }else{ = one[0] - one[1] } if(two[0] > two[1]){ b = two[1] - two[0] }else{ b = two[0] - two[1] } var c = a^2 + b^2; return math.sqrt(c); } radius = distance([centerx,e.clientx], [centery,e.clienty]) context.fillcircle(centerx, centery, radius, "white");
as can see, circle far short , don't know why... when remove sqrt, becomes out of whack quickly.
^
not think does.
js> 8^2 10 js> math.pow(8,2) 64
Comments
Post a Comment