forked from mrdoob/texgen.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathanimated.html
82 lines (63 loc) · 2.19 KB
/
animated.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>texgen.js</title>
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<style>
body {
margin: 20px;
background: #111;
}
</style>
</head>
<body>
<script src="../src/TexGen.js"></script>
<script>
var i = 0;
var size = 300;
var canvas = document.createElement("canvas");
canvas.width = size * 3;
canvas.height = size;
document.body.appendChild( canvas );
var context = canvas.getContext("2d");
animate();
function render() {
var texture = new TG.Texture( size, size )
.add( new TG.SinX().frequency( 0.05+i/1000 ) )
.mul( new TG.SinX().frequency( 0.08-i/2000 ) )
.add( new TG.SinY().frequency( 0.05-i/1000 ) )
.mul( new TG.SinY().frequency( 0.08+i/2000 ) )
.div( new TG.Number().tint( 1, 2, 1 ) )
.add( new TG.SinX().frequency( 0.003 ).tint( 0.5, 0, 0 ) )
.toImageData(context);
context.putImageData( texture, 0, 0 );
//
var texture = new TG.Texture( size, size )
.add( new TG.SinX().frequency( 0.066 + 0.05*Math.sin(i/100) ) )
.add( new TG.SinY().frequency( 0.066 + 0.05*Math.sin(i/100) ) )
.mul( new TG.SinX().offset( 32 ).frequency( 0.044 + 0.09*Math.sin(i/100) ).tint( 2, 2, 2 ) )
.mul( new TG.SinY().offset( 16 ).frequency( 0.044 + 0.09*Math.sin(i/100) ).tint( 2, 2, 2 ) )
.sub( new TG.Number().tint( 0.5, 2, 4 ) )
.toImageData(context);
context.putImageData( texture, size, 0 );
//
var texture = new TG.Texture( size, size )
.add( new TG.SinX().frequency( 0.004 + 0.002*Math.sin(i/100)) )
.mul( new TG.SinY().frequency( 0.004 + 0.002*Math.sin(i/100)) )
.mul( new TG.SinY().offset( 32 ).frequency( 0.04 + 0.02*Math.sin(i/100) ) )
.div( new TG.SinX().frequency( 0.02 ).tint( 8, 5, 4 ) )
.add( new TG.Noise().tint( 0.1, 0, 0 ) )
.add( new TG.Noise().tint( 0, 0.1, 0 ) )
.add( new TG.Noise().tint( 0, 0, 0.1 ) )
.toImageData(context);
context.putImageData( texture, size * 2, 0 );
i++;
}
function animate() {
requestAnimationFrame( animate );
render();
}
</script>
</body>
</html>