forked from apaleyes/penrose-tiling
-
Notifications
You must be signed in to change notification settings - Fork 0
/
penrose.html
146 lines (143 loc) · 4.84 KB
/
penrose.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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<style type="text/css">
html,body {
height:100%;
margin: 0;
padding: 0;
font-family: sans-serif;
}
html {
margin: 0.5em;
}
#wrapper {
width: 100%;
height: 100%;
position: relative;
}
#menu {
position: absolute;
width: 20em;
float: left;
}
#readout {
position:absolute;
top: 1em;
right: 1em;
}
#github {
position:absolute;
top: 1em;
right: 15em;
}
#github img {
width: 4em;
}
svg {
width: 100%;
height: 50%;
}
svg#gnomon {
height: 40%;
}
svg path.robinson {
stroke-width: 1px;
stroke: black;
fill: none;
}
svg path.polygon {
stroke-width: 2px;
stroke: turquoise;
fill: none;
stroke-opacity: .4;
pointer-events: none;
}
svg text {
font-family: sans-serif;
font-size: 10pt;
text-anchor: middle;
dominant-baseline: middle;
pointer-events: none;
}
svg#tiles text {
font-size: 8pt;
}
svg#tiles text.side {
font-size: 6pt;
}
svg#tiles text.robinson.C, svg#tiles text.robinson.D, svg#tiles text.side.C, svg#tiles text.side.D {
fill: #baa;
}
svg#tiles text.robinson.over, svg#tiles text.robinson.side0, svg#tiles text.robinson.side2, svg#tiles text.robinson.side3,
/* svg#tiles text.side.highlight */
{
fill: black;
}
svg path.over {
fill-opacity: .2;
}
svg path.side0 {
fill: green !important;
}
svg path.side1 {
fill: #d60 !important;
}
svg path.side2 {
fill: darkviolet !important;
}
svg path.side3 {
fill: #e7298a !important;
}
</style>
<script src="d3.v7.min.js"></script>
</head>
<body onload="drawPenroseTiling();">
<div id="menu">
<fieldset>
<p>Initial shape</p>
<div>
<input type="radio" name="init_shape" value="square" checked="checked">
<label>Square</label>
<input type="radio" name="init_shape" value="pentagon">
<label>Pentagon</label>
<input type="radio" name="init_shape" value="hexagon">
<label>Hexagon</label>
</div>
</fieldset>
<fieldset>
<p>Approximate minimum tiles</p>
<input type="range" id="minimum" name="Minimum" min="0" max="1000" oninput="minimumOutput.value = minimum.value" value="50" />
<output id="minimumOutput">50</output>
</fieldset>
<fieldset>
<p>Resolve ragged border</p>
<div>
<input id="ragged-none" type="radio" name="resolve_ragged" value="none">
<label for="ragged-none">None</label>
<input id="ragged-cull" type="radio" name="resolve_ragged" value="cull" checked="checked">
<label for="ragged-cull">Cull</label>
<input id="ragged-fill" type="radio" name="resolve_ragged" value="fill">
<label for="ragged-fill">Fill</label>
</div>
</fieldset>
<input type="button" onclick="drawPenroseTiling();" value="Draw" />
</div>
<div id="github"><a href="https://github.com/gordonwoodhull/penrose-fill-polygon">
<img src="github-mark.png"></a></div>
<div id="readout"></div>
<svg id="gnomon">
<g id="triangles"></g>
<g id="polygon"></g>
</svg>
<svg id="tiles">
<g id="rhombuses"></g>
<g id="triangles"></g>
<g id="coord"></g>
<g id="polygon"></g>
</svg>
<script type="text/javascript" src="penrose-bundle.js"></script>
<script type="text/javascript" src="penrose-fill-demo.js"></script>
</body>
</html>