-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample3.html
58 lines (51 loc) · 1.6 KB
/
example3.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
<!doctype html>
<html class="no-js" lang="">
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title>Penrose tiles #3</title>
<meta name="description" content="A star with five-fold symmetry">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="manifest" href="site.webmanifest">
<link rel="apple-touch-icon" href="icon.png">
<style type="text/css">
html { height: 100%; }
body { display: contents; }
#image { height: 100%; }
</style>
</head>
<body>
<div id="image"></div>
<script type="module">
import { Complex, PenroseP3, BtileL, psi } from './penrose.js';
(function(el) {
const phi = 1 / psi;
const scale = 100;
const config = {'draw-arcs': true,
'Aarc-colour': '#ff5e25',
'Carc-colour': 'none',
'Stile-colour': '#090',
'Ltile-colour': '#9f3',
'rotate': Math.PI / 2
};
const tiling = new PenroseP3(scale*2, 5, config);
const theta = 2 * Math.PI / 5;
const rot = new Complex(Math.cos(theta), Math.sin(theta));
const B1 = new Complex(scale, 0);
const p = rot.mult(B1);
const q = rot.mult(p);
const C5 = new Complex(-scale * phi, 0);
const r = C5.div(rot);
const s = r.div(rot);
const A = [0, 0, 0, 0, 0];
const B = [scale, p, p, q, q];
const C = [s, s, r, r, C5];
tiling.set_initial_tiles(A.map((a, index) => (new BtileL(A[index], B[index], C[index]))));
tiling.make_tiling();
const img = tiling.make_svg();
// console.log(img);
el.innerHTML = img;
})(document.getElementById('image'));
</script>
</body>
</html>