blob: e63a72898c3e7eac54141790e8f2c86cf5ba20e6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
<!doctype html>
<html>
<head>
<title>Shader</title>
<style type="text/css">
#url { width: 100px; }
#width,#height,#frames,#delay {width: 30px; }
#shader { width: 400px; height: 247px; font-family: fixed; }
div { float: left; padding: 10px;}
</style>
</head>
<body>
<div id="controls">
<input type="text" id="url" value="img/1376516658960-dumpfm-DoritoWitch-TimeFLyTrans0001.png">
<!--
frames <input type="text" id="frames" value="7">
delay <input type="text" id="delay" value="60">
-->
<button id="render" disabled>render</button>
<button id="demo">demo</button>
<button id="dither-demo">dither</button>
<br>
<br>
<textarea id="shader">
</textarea>
</div>
<div id="workspace">
</div>
</body>
<script type="text/javascript" src="js/vendor/jquery/jquery.min.js"></script>
<script type="text/javascript" src="js/vendor/gif.js"></script>
<script type="text/javascript" src="js/vendor/canvasquery.js"></script>
<script type="text/javascript" src="js/canvasquery.dither.js"></script>
<script type="text/javascript" src="js/color.js"></script>
<script type="text/javascript" src="js/image.js"></script>
<script type="text/javascript" src="js/render.js"></script>
<script type="text/javascript" src="js/shader.js"></script>
<script type="text/javascript" src="js/util.js"></script>
<script type="text/javascript">
var cc = cq(0,0).appendTo("#workspace")
var w, h
$(init)
function init(){
$("#url").change(load)
$("#demo").click(function(){ run("#first") })
$("#dither-demo").click(function(){ run("#second") })
run('#first')
load()
document.getElementById('shader').addEventListener('input', shader_build);
shader_build()
requestAnimationFrame(animate)
}
function run(el){
$el = $(el)
s = $el.html()
$("#shader").html(s)
shader_build()
}
function status(s){$("#status").html(s)}
</script>
<script type="text/javascript-shader" id="first">
t /= 500
if (a == 0) { r = g = b = x; t /= -3 }
r *= (Math.sin(t*x/y) + 1)/2
g *= (Math.cos(t*y/x) + 0.4)/2
b *= (Math.sin(t) + 1.5)/2
a = y
</script>
<script type="text/javascript-shader" id="second">
xx = x, yy = y
var d = ((x % 2) + 2 * (y % 2)) - 2
x += w/2
y -= h/2
t/=-200
y/=96
x/=50
v = (Math.sin(t+x*y) + 1.0) / 2
v = (0.6) * v - 0.4 + Math.random()
v = clamp( v*64 + 128 , 0, 255)
v += d*32
if (a == 0) r = g = b = xx/w * 255
a = v > 128 ? v:0
</script>
</html>
|