summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjules <jules@okfoc.us>2015-02-23 14:06:54 -0500
committerjules <jules@okfoc.us>2015-02-23 14:06:54 -0500
commit673f9b22840417c8de68e5311fb6dcb76b9b35ca (patch)
treef9dbda0b1b0e6e9da9b3775b2d5a282c80c62af1
parent7e21f72384f24621ad060fecc49cff186167f523 (diff)
parentd5886f67ee6edbafc759410e92917593dc9329a0 (diff)
Merge branch 'master' of lmno:dither
-rwxr-xr-xcgi-bin/proxy28
-rw-r--r--index.html8
-rw-r--r--js/util.js31
-rw-r--r--shader-combo.html2
4 files changed, 59 insertions, 10 deletions
diff --git a/cgi-bin/proxy b/cgi-bin/proxy
index 9c2ca3d..5e3539c 100755
--- a/cgi-bin/proxy
+++ b/cgi-bin/proxy
@@ -2,6 +2,8 @@
from os import environ as env
import urllib.request
+import base64
+import json
import sys
def error():
@@ -9,18 +11,30 @@ def error():
print()
print("HELLO!")
-def proxy(url,ext):
+def proxy(url,ext,callback):
req = urllib.request.urlopen(url)
- print("Content-type: image/" + ext)
- print()
- sys.stdout.flush()
- sys.stdout.buffer.write( req.read() )
+ if callback != "":
+ print("Content-type: text/plain")
+ print()
+ sys.stdout.flush()
+ sys.stdout.buffer.write( bytes( callback + "(" + json.dumps( "".join(map(chr, base64.b64encode( req.read() )))) + ")" , 'utf-8'))
+ else:
+ print("Content-type: image/" + ext)
+ print()
+ sys.stdout.flush()
+ sys.stdout.buffer.write( req.read() )
+
+qs = env['QUERY_STRING'].split('&callback=')
+if len(qs) == 2:
+ callback = qs[1]
+else:
+ callback = ''
+path = qs[0]
-path = env['QUERY_STRING']
ext = path[-3:].lower()
if path[0:4] == "http" and ext in ("gif","jpg","png","peg"):
- proxy(path,ext)
+ proxy(path,ext,callback)
else:
error()
diff --git a/index.html b/index.html
index 5d51485..94a11ce 100644
--- a/index.html
+++ b/index.html
@@ -48,12 +48,18 @@ h1 { font-size: 26px; font-weight: normal }
<a target="_blank" href="/imgrid/"><button>im-grid</button></a>
<a target="_blank" href="/imbreak/"><button>im-break</button></a>
+<h1>colorcodes</h1>
+<a target="_blank" href="/ascii/"><button>ascii-shader</button></a>
+<a target="_blank" href="/ascii/image.html"><button>ascii-image</button></a>
+<a target="_blank" href="/ascii/colors.html"><button>ascii-colors</button></a>
+<a target="_blank" href="/xdcc/"><button>xdcc.pl</button></a>
+
<h1>etc..</h1>
<a target="_blank" href="/gif-recorder/"><button>gif-recorder</button></a>
<a target="_blank" href="/neighbor/"><button>neighbor</button></a>
...
<a target="_blank" href="/dendrite/"><button>dendrite</button></a>
-<a target="_blank" href="/dendrite/dendrite-life.html"><button>dendrite-life</button></a>
+<a target="_blank" href="/dendrite/life.html"><button>dendrite-life</button></a>
<a target="_blank" href="/mandel/mandel5.html"><button>mandel5</button></a>
<a target="_blank" href="http://glitchyplop.com/"><button>sortpixels</button></a>
<a target="_blank" href="/strobe/"><button>strobe</button></a>
diff --git a/js/util.js b/js/util.js
index 80fce9c..f76fc8e 100644
--- a/js/util.js
+++ b/js/util.js
@@ -36,7 +36,7 @@ function tan(n){ return Math.tan(n) }
function acos(n){ return Math.cos(n) }
function asin(n){ return Math.sin(n) }
function atan(n){ return Math.atan(n) }
-function atan2(n){ return Math.atan2(n) }
+function atan2(a,b){ return Math.atan2(a,b) }
function sec(n){ return 1/cos(n) }
function csc(n){ return 1/sin(n) }
function cot(n){ return 1/tan(n) }
@@ -114,3 +114,32 @@ function weave(a){
reverse(aa[1]).forEach(function(el){ b.push(el) })
return b
}
+
+// easing functions
+function circular (t) { return Math.sqrt( 1 - ( --t * t ) ) }
+function quadratic (t) { return t * ( 2 - t ) }
+function back (t) {
+ var b = 4;
+ return ( t = t - 1 ) * t * ( ( b + 1 ) * t + b ) + 1;
+}
+function bounce (t) {
+ if (t >= 1) return 1;
+ if ( ( t /= 1 ) < ( 1 / 2.75 ) ) {
+ return 7.5625 * t * t;
+ } else if ( t < ( 2 / 2.75 ) ) {
+ return 7.5625 * ( t -= ( 1.5 / 2.75 ) ) * t + 0.75;
+ } else if ( t < ( 2.5 / 2.75 ) ) {
+ return 7.5625 * ( t -= ( 2.25 / 2.75 ) ) * t + 0.9375;
+ } else {
+ return 7.5625 * ( t -= ( 2.625 / 2.75 ) ) * t + 0.984375;
+ }
+}
+function elastic (t) {
+ var f = 0.22,
+ e = 0.4;
+
+ if ( t === 0 ) { return 0; }
+ if ( t == 1 ) { return 1; }
+
+ return ( e * Math.pow( 2, - 10 * t ) * Math.sin( ( t - f / 4 ) * ( 2 * Math.PI ) / f ) + 1 );
+}
diff --git a/shader-combo.html b/shader-combo.html
index 54f4329..d2147a5 100644
--- a/shader-combo.html
+++ b/shader-combo.html
@@ -30,7 +30,7 @@ a { color: #00f; }
.ui-sortable-helper { cursor: -webkit-grabbing !important; }
#commands { top:40px;right:20px; width:190px;height:calc(95% - 230px); }
-#tutorial { top:40px;right:30px; width:290px;height:360px; display: block;}
+#tutorial { top:40px;right:30px; width:290px;height:360px; display: none;}
.iframe { position: absolute; box-shadow:5px 5px 10px rgba(0,0,0,0.3); background:rgba(255,255,255,0.8); display: none; cursor: -webkit-grab; }
.iframe iframe {width: 100%;height:100%;margin:0;padding:0;border:0;}
.iframe.dragging iframe { pointer-events: none; }