From fb322430f61b32af4e22d5136704ce87ddfd6f3a Mon Sep 17 00:00:00 2001 From: jules Date: Sun, 26 Jan 2014 02:55:13 -0500 Subject: actual_w, actual_h to fix rgbpixel on resized workspace --- js/util.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/util.js') diff --git a/js/util.js b/js/util.js index 7bb1c78..5e85c3b 100644 --- a/js/util.js +++ b/js/util.js @@ -43,7 +43,7 @@ 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 pixel(x,y){ return 4*(mod(y,h)*w+mod(x,w)) } +function pixel(x,y){ return 4*(mod(y,actual_h)*actual_w+mod(x,actual_w)) } function rgbpixel(d,x,y){ var p = pixel(~~x,~~y) r = d[p] -- cgit v1.2.3-70-g09d2 From c030a4c619c4fc6182cc9b266241ce1970174a40 Mon Sep 17 00:00:00 2001 From: jules Date: Sun, 26 Jan 2014 04:38:18 -0500 Subject: try to proxy https as http --- js/image.js | 2 +- js/render.js | 4 ++-- js/util.js | 10 ++++++---- 3 files changed, 9 insertions(+), 7 deletions(-) (limited to 'js/util.js') diff --git a/js/image.js b/js/image.js index 1f36473..3138299 100644 --- a/js/image.js +++ b/js/image.js @@ -38,7 +38,7 @@ function giveImage(t) { function proxify (url) { if (url.indexOf("http") == 0) - return "/cgi-bin/proxy?" + url.replace(/^https?:\/\//, ""); + return "/cgi-bin/proxy?" + url.replace(/^https/, "http"); else return url } diff --git a/js/render.js b/js/render.js index 4de7329..7f0e672 100644 --- a/js/render.js +++ b/js/render.js @@ -5,8 +5,8 @@ var fps = 30 function choose (){ loading = true - $("#url").val(imageURL) - loadImage(imageURL, ready) + $("#url").val(this.src) + loadImage(this.src, ready) } function load(){ diff --git a/js/util.js b/js/util.js index 5e85c3b..cecb210 100644 --- a/js/util.js +++ b/js/util.js @@ -43,6 +43,11 @@ 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 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 } + function pixel(x,y){ return 4*(mod(y,actual_h)*actual_w+mod(x,actual_w)) } function rgbpixel(d,x,y){ var p = pixel(~~x,~~y) @@ -51,10 +56,7 @@ function rgbpixel(d,x,y){ b = d[p+2] a = d[p+3] } -function mod(n,m){ return n-(m * floor(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 } +function fit(d,x,y){ rgbpixel(d,x*actual_w/w,y*actual_h/h) } function step(a, b){ return (b >= a) + 0 -- cgit v1.2.3-70-g09d2 From 190e3d4cf52c12f49c24adde79427ac9e85ac2b1 Mon Sep 17 00:00:00 2001 From: jules Date: Mon, 17 Feb 2014 15:08:57 -0500 Subject: randrange --- js/util.js | 2 ++ 1 file changed, 2 insertions(+) (limited to 'js/util.js') diff --git a/js/util.js b/js/util.js index cecb210..dd5be06 100644 --- a/js/util.js +++ b/js/util.js @@ -6,6 +6,7 @@ if (window.$) { $.fn.disable = function() { return $(this).attr("disabled","disabled") } } +function noop(){} function trim(s){ return s.replace(/^\s+/,"").replace(/\s+$/,"") } var E = Math.E @@ -39,6 +40,7 @@ function sinp(n){ return (1+Math.sin(n))/2 } function random(){ return Math.random() } function rand(n){ return (Math.random()*n) } function randint(n){ return rand(n)|0 } +function randrange(a,b){ return a + rand(b-a) } function choice(a){ return a[randint(a.length)] } function deg(n){ return n*180/PI } function rad(n){ return n*PI/180 } -- cgit v1.2.3-70-g09d2 From f2e65b33288a249e2c2a8a9677701b634d15f1bc Mon Sep 17 00:00:00 2001 From: jules Date: Mon, 17 Feb 2014 17:20:57 -0500 Subject: TWO_PI --- js/util.js | 1 + 1 file changed, 1 insertion(+) (limited to 'js/util.js') diff --git a/js/util.js b/js/util.js index dd5be06..d775ca1 100644 --- a/js/util.js +++ b/js/util.js @@ -12,6 +12,7 @@ function trim(s){ return s.replace(/^\s+/,"").replace(/\s+$/,"") } var E = Math.E var PI = Math.PI var PHI = (1+Math.sqrt(5))/2 +var TWO_PI = PI*2 function clamp(n,a,b){ return n Date: Tue, 18 Feb 2014 08:48:42 -0500 Subject: norm --- js/util.js | 1 + 1 file changed, 1 insertion(+) (limited to 'js/util.js') diff --git a/js/util.js b/js/util.js index d775ca1..e0b7166 100644 --- a/js/util.js +++ b/js/util.js @@ -14,6 +14,7 @@ var PI = Math.PI var PHI = (1+Math.sqrt(5))/2 var TWO_PI = PI*2 function clamp(n,a,b){ return n Date: Wed, 19 Feb 2014 23:23:19 -0500 Subject: can't believe i forgot log --- js/util.js | 3 +++ 1 file changed, 3 insertions(+) (limited to 'js/util.js') diff --git a/js/util.js b/js/util.js index e0b7166..66d5757 100644 --- a/js/util.js +++ b/js/util.js @@ -13,6 +13,7 @@ var E = Math.E var PI = Math.PI var PHI = (1+Math.sqrt(5))/2 var TWO_PI = PI*2 +var LN10 = Math.LN10 function clamp(n,a,b){ return n Date: Fri, 21 Feb 2014 17:40:03 -0500 Subject: fix sqrt --- js/util.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'js/util.js') diff --git a/js/util.js b/js/util.js index 66d5757..218b845 100644 --- a/js/util.js +++ b/js/util.js @@ -29,7 +29,7 @@ function pow(n,b) { return Math.pow(n,b) } function exp(n) { return Math.exp(n) } function log(n){ return Math.log(n) } function ln(n){ return Math.log(n)/LN10 } -function sqrt(n) { return Math.sqrt(n,b) } +function sqrt(n) { return Math.sqrt(n) } function cos(n){ return Math.cos(n) } function sin(n){ return Math.sin(n) } function tan(n){ return Math.tan(n) } @@ -70,8 +70,9 @@ function step(a, b){ // ^^ bool -> int } + function julestep (a,b,n) { - return clamp((n - a) / (b - a), 0.0, 1.0); + return clamp(norm(n,a,b), 0.0, 1.0); } // hermite curve apparently -- cgit v1.2.3-70-g09d2 From dcf5ddffe94d7d18a8411c910ab53192841919de Mon Sep 17 00:00:00 2001 From: jules Date: Wed, 26 Feb 2014 16:13:16 -0500 Subject: lol max and min were wrong --- 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 218b845..f1fd3c2 100644 --- a/js/util.js +++ b/js/util.js @@ -21,8 +21,8 @@ function mix(n,a,b){ return a*(1-n)+b*n } function ceil(n){ return Math.ceil(n) } function floor(n){ return Math.floor(n) } function round(n){ return Math.round(n) } -function max(n){ return Math.max(n) } -function min(n){ return Math.min(n) } +function max(a,b){ return Math.max(a,b) } +function min(a,b){ return Math.min(a,b) } function abs(n){ return Math.abs(n) } function sign(n){ return Math.abs(n)/n } function pow(n,b) { return Math.pow(n,b) } -- cgit v1.2.3-70-g09d2 From ecf09db071416e56112a3343f7a190ffdbd2bbe1 Mon Sep 17 00:00:00 2001 From: Jules Date: Thu, 8 May 2014 12:51:28 -0400 Subject: randsign --- js/util.js | 1 + 1 file changed, 1 insertion(+) (limited to 'js/util.js') diff --git a/js/util.js b/js/util.js index f1fd3c2..c3940d3 100644 --- a/js/util.js +++ b/js/util.js @@ -46,6 +46,7 @@ function random(){ return Math.random() } function rand(n){ return (Math.random()*n) } function randint(n){ return rand(n)|0 } function randrange(a,b){ return a + rand(b-a) } +function randsign(){ return random() >= 0.5 ? -1 : 1 } function choice(a){ return a[randint(a.length)] } function deg(n){ return n*180/PI } function rad(n){ return n*PI/180 } -- cgit v1.2.3-70-g09d2 From 769fd4e9b93bf2130527ed7bad661ce17f4cf550 Mon Sep 17 00:00:00 2001 From: jules Date: Mon, 8 Sep 2014 12:27:00 -0400 Subject: quantize() --- js/util.js | 1 + 1 file changed, 1 insertion(+) (limited to 'js/util.js') diff --git a/js/util.js b/js/util.js index c3940d3..80fce9c 100644 --- a/js/util.js +++ b/js/util.js @@ -55,6 +55,7 @@ function mod(n,m){ return n-(m * floor(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 } +function quantize(a,b){ return ~~(a/b)*b } function pixel(x,y){ return 4*(mod(y,actual_h)*actual_w+mod(x,actual_w)) } function rgbpixel(d,x,y){ -- cgit v1.2.3-70-g09d2