-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
118 lines (105 loc) · 3.45 KB
/
index.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Galton board</title>
<style>
:root {
--app-width: 800px;
--app-height: 600px;
/** matter.js app layout parameters */
--app-top-peg-y: 100;
--app-bottom-peg-row-size: 9;
--app-spacing: 30;
--app-bead-period-in-millis: 200;
--app-bead-start-position-range-begin: -3;
--app-bead-start-position-range-end: 3;
--app-bead-size: 6;
--app-peg-size: 4;
--yellow: #e1c440;
--light-purple: #d138d3;
--dark-purple: #26002b;
--green: #2a780f;
}
body {
margin: 0;
padding: 0;
background-color: var(--dark-purple);
color: var(--yellow);
font-family: sans-serif;
font-size: 16px;
}
p {
line-height: 1.5em;
}
p.footer {
font-size: 14px;
}
canvas {
position: absolute;
display: block;
border-top: 1px solid var(--light-purple);
border-bottom: 1px solid var(--light-purple);
}
a, a:active, a:hover, a:visited {
color: var(--light-purple);
text-decoration: none;
}
hr {
height: 0;
border: 0;
border-top: 1px solid var(--light-purple);
}
.title {
margin: 20px 0;
height: 30px;
}
.container {
margin: 10px auto;
width: var(--app-width);
position: relative;
}
.demo {
width: var(--app-width);
height: var(--app-height);
margin-bottom: 40px;
}
.right {
text-align: right;
}
.youtube-thumbnail {
position: absolute;
right: 0;
top: 0;
width: 105px;
height: 60px;
background: url(youtube.png) center no-repeat;
background-size: contain;
}
</style>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-101273659-1', 'auto');
ga('send', 'pageview');
</script>
</head>
<body>
<div class="container">
<img class="title" src="title.svg" alt="title">
<div class="demo">
<canvas id="background-canvas"></canvas>
<canvas id="matter-canvas"></canvas>
<a href="https://youtu.be/UCmPmkHqHXk" target="_blank" title="Michael Stevens explaining how the Galton board works">
<div class="youtube-thumbnail"></div>
</a>
</div>
<p>This demo uses <a href="http://brm.io/matter-js/" target="_blank">Matter.js</a> to simulate a Galton board, accumulating the contribution of each fallen bead to the distribution graph, which is expected to converge to a bell curve as the simulation progresses.</p>
<p class="right footer">Made by <a href="//luciopaiva.com" target="_blank">Lucio Paiva</a>, Sep. 2018.</p>
</div>
<script src="matter.min.js"></script>
<script src="index.js"></script>
</body>
</html>