-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
204 lines (160 loc) · 4.74 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
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>neoquip</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
body {
margin: 20px;
}
main {
font-size: 30px;
font-family: sans-serif;
text-align: center;
}
footer {
font-size: 20px;
font-family: sans-serif;
}
.neoquip {
display: flex;
flex-direction: row;
justify-content: center;
transform: scale(0.5);
transform-origin: top;
}
.cord {
display: flex;
flex-direction: column;
align-items: flex-start;
background: url('img/cord-tile.png') repeat-y;
margin: 50px 20px;
}
.knot {
display: block;
margin: 0 8px;
width: 200px;
height: 200px;
background-repeat: no-repeat;
}
/*
Use Artillery_loop for zero
https://en.wikipedia.org/wiki/Artillery_loop
*/
.knot-0 {
background-image: url('img/knot-0.png');
background-position-x: 20px;
}
.knot-1 {
background-image: url('img/knot-1.png');
background-position-x: -8px;
}
.knot-2 {
background-image: url('img/knot-2.png');
background-position-x: -4px;
}
.knot-3 {
background-image: url('img/knot-3.png');
background-position-x: 0px;
}
.knot-4 {
background-image: url('img/knot-4.png');
background-position-x: -4px;
}
.knot-5 {
background-image: url('img/knot-5.png');
background-position-x: -9px;
}
.knot-6 {
background-image: url('img/knot-6.png');
background-position-x: -4px;
}
.knot-7 {
background-image: url('img/knot-7.png');
background-position-x: -6px;
}
.knot-8 {
background-image: url('img/knot-8.png');
background-position-x: -9px;
}
.knot-9 {
background-image: url('img/knot-9.png');
background-position-x: -9px;
}
.knot-end {
background-image: url('img/knot-end.png');
background-position-y: bottom;
background-position-x: -6px;
flex-grow: 1;
}
#input {
font-size: 22px;
padding: 4px;
width: 20em;
max-width: 100%;
box-sizing: border-box;
border: 1px solid #333;
text-align: center;
}
#neoquip {
margin: 4 0px 0;
}
</style>
</head>
<body>
<main>
<h1>neoquip</h1>
<p>An experimental rope encoding of numbers based on Quipu (Khipu)</p>
<input id="input" type="text" autofocus="autofocus" placeholder="Enter numbers, separated by commas" />
<div class="neoquip"></div>
</main>
<footer>
<p>This site was created as part of the
<a href="https://www.gold.ac.uk/pg/ma-computational-arts/">Goldsmiths Computation Arts MA</a> 2018 by
<a href="https://aubergene.com">Julian Burgess</a> &
<a href="https://izzymclellan.com/">Izzy Mclellan</a>.
<a href="https://github.com/aubergene/neoquip">More information</a>.</p>
</footer>
<script src="d3.js"></script>
<script>
var el = d3.select('.neoquip')
var input = d3.select('#input')
input.on('input', function() {
render(this.value)
})
if (location.hash) {
render(location.hash)
} else {
if (window.innerWidth < 600) {
render('123, 642')
} else {
render('7,15,12,4,19,13,9,20,8,19')
}
}
function render(val) {
el.selectAll('.cord').remove()
var data = val.replace(/[^0-9,]/g, '')
console.log(data)
input.node().value = data
window.location.hash = data
data = data.split(',')
if (!data.length || data.length === 1 && data[0] === '') return
var cords = el.selectAll('.cord')
.data(data)
.enter()
.append('div')
.classed('cord', true)
.style('background-position', (d, i) => '0% ' + (i / data.length) * 100 + '%')
var knots = cords.selectAll('.knot')
.data(d => d.toString().split(''))
.enter()
.append('div')
.attr('class', (d) => `knot knot-${d}`)
cords.append('div')
.attr('class', 'knot knot-end')
}
</script>
</body>
</html>