summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
Diffstat (limited to 'js')
-rw-r--r--js/image.js2
-rw-r--r--js/render.js4
-rw-r--r--js/util.js10
3 files changed, 9 insertions, 7 deletions
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