-
Notifications
You must be signed in to change notification settings - Fork 1
/
centripodes.html
74 lines (60 loc) · 1.81 KB
/
centripodes.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
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
<script src="bower_components/fabric/dist/fabric.js"></script>
<script src="bower_components/noisejs/index.js"></script>
<script src="bower_components/tinycolor/tinycolor.js"></script>
<script src="js/common.js"></script>
<style>
body {
margin : 0;
padding: 0;
}
</style>
</head>
<body>
<p>WORK IN PROGRESS: Generates symmetric bit sculptures using simplex noise starting from one point in the matrix</p>
<canvas id="c"></canvas>
<script>
var w = 5;
var h = 5;
var side = 100;
var canvas = new fabric.Canvas('c');
canvas.setWidth(w * side * 2);
canvas.setHeight(h * side);
var bg = getRandomColor();
var fg = tinycolor.complement(bg).toHexString();
var noise = new Noise(Math.random());
canvas.setBackgroundColor(bg, function() {
canvas.renderAll();
});
var ink = Math.random() * 10; // All the ink i have for painting - somewhere between 0 and ten pixels :(
var i = w - 1;
var j = Math.ceil((h - 1) / 2);
var fill = fg;
var matrix = [];
for (var a=0;a<w;a++) {
matrix[a] = [];
for (var b=0;b<h;b++) {
matrix[a][b] = { visited : 0, colored : 0};
}
}
while (ink > 0)
{
var n = noise.simplex2(i, j);
if (n > 0) {
canvas.add(new fabric.Rect({
left : side * i,
top : side * j,
width : side,
height : side,
fill : fill
}));
ink--;
}
}
</script>
</body>
</html>