From 448e55b683d9eeda3fd0f6c96287a4f3b70bc9a1 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Fri, 3 Jun 2016 20:30:16 -0400 Subject: phat brushes --- js/util.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'js/util.js') diff --git a/js/util.js b/js/util.js index cdabbe1..f2fd129 100644 --- a/js/util.js +++ b/js/util.js @@ -58,8 +58,8 @@ function choice(a){ return a[randint(a.length)] } function deg(n){ return n*180/PI } function rad(n){ return n*PI/180 } function xor(a,b){ a=!!a; b=!!b; return (a||b) && !(a&&b) } -function mod(n,m){ return n-(m * floor(n/m)) } -function modi(n,m){ return floor(n-(m * floor(n/m))) } +function mod(n,m){ n = n % m; return n < 0 ? (m + n) : n } +function modi(n,m){ return floor(mod(n,m)) } function dist(x0,y0,x1,y1){ return sqrt(pow(x1-x0,2)+pow(y1-y0,2)) } function angle(x0,y0,x1,y1){ return atan2(y1-y0,x1-x0) } function avg(m,n,a){ return (m*(a-1)+n)/a } -- cgit v1.2.3-70-g09d2