-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
355 lines (291 loc) · 14.3 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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
<!DOCTYPE html>
<html lang="en">
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.4.0/p5.js"></script>
<meta charset="utf-8"/>
<title>Urban Park Design Using Wave Function Collapse</title>
<link rel="icon" type="image/x-icon" href="/assets/images/favicon.ico">
<link rel="stylesheet" href="assets/styles/index.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Open+Sans:ital,wght@0,300..800;1,300..800&display=swap"
rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Bungee&display=swap" rel="stylesheet">
</head>
<body class="scrollbar">
<div class="container">
<div class="content">
<div class="content-left">
<h3 class="open-sans-700">Ground types:</h3>
<div class="option types" id="types"></div>
<h3 class="open-sans-700">Seasons:</h3>
<div class="option seasons scrollbar" id="seasons"></div>
<h3 class="open-sans-700">Categories:</h3>
<div class="option categories scrollbar" id="categories"></div>
</div>
<div class="content-center">
<div class="title">
<h1 class="bungee">ISOMETRIC PARK DESIGN</h1>
<span id="myBtn" class="material-icons">info_outlined</span>
</div>
<main></main>
<div class="buttons">
<button class="button open-sans-500 generate" onclick="resetFunction()">Generate</button>
<div class="sub-buttons">
<div class="button-with-info">
<span style="width: 48px"></span>
<button class="button open-sans-500" onclick="resetEntireGrid()">Reset Grid</button>
<span class="tooltip material-icons">
help_outline
<span class="tooltip-text open-sans-500">
Reset all the rules of the grid.
</span>
</span>
</div>
<div class="button-with-info">
<div style="width: 48px"></div>
<button class="button open-sans-500" onclick="emptyGrid()">Empty Grid</button>
<span class="tooltip material-icons">
help_outline
<span class="tooltip-text open-sans-500">
Create an empty grid with no items.
</span>
</span>
</div>
</div>
</div>
</div>
<div class="content-right" id="optionsContainer">
<h3 class="open-sans-700" id="tileTitle"></h3>
<div class="cell-options scrollbar" id="tileOptions"></div>
<h3 class="open-sans-700" id="itemTitle"></h3>
<div class="cell-options scrollbar" id="itemOptions">
<h2 class="open-sans-700"><span style="margin-right: 8px;" class="material-icons">ads_click</span>Select
a cell to edit it.</h2>
</div>
</div>
</div>
</div>
<div class="instructions modal" id="myModal">
<div class="modal-content">
<span class="material-icons close">close</span>
<div class="modal-text scrollbar">
<h1 class="bungee">Instructions</h1>
<p class="open-sans-500">Welcome to the Urban Park Design Tool! This tool allows you to create urban park
designs using a wave function collapse algorithm. Choose from various ground types, seasons, and
categories to create unique park designs. Follow these simple instructions:</p>
<h3 class="open-sans-700">Ground Types</h3>
<p class="open-sans-500">Select from different base tiles like river, water, path and sand to set the foundation
of your park. Combine them to create interesting patterns.</p>
<h3 class="open-sans-700">Seasons</h3>
<p class="open-sans-500">Choose a season (spring, summer, fall, winter) to see the trees in different colors.</p>
<h3 class="open-sans-700">Categories</h3>
<p class="open-sans-500">Pick items from categories like trees, flowers, benches, and paths to add variety
to your park. Mix and match to create a unique design.</p>
<h3 class="open-sans-700">Generate Button</h3>
<p class="open-sans-500">Click "Generate" to create a new park design based on your selections. Use this
button to explore different layouts.</p>
<h3 class="open-sans-700">Reset Grid Button</h3>
<p class="open-sans-500">Use "Reset Grid" to clear the grid and start fresh with default settings.</p>
<h3 class="open-sans-700">Empty Grid Button</h3>
<p class="open-sans-500">Click "Empty Grid" to remove all items but keep your ground types, seasons, and
categories the same for a blank canvas.</p>
<h3 class="open-sans-700">Selecting Cell</h3>
<p class="open-sans-500">Click a cell to select it. Then choose an item or ground type from the options on
the right to place in the selected cell.</p>
<h3 class="open-sans-700">Tile Options</h3>
<p class="open-sans-500">Choose different ground types like river, water, path and sand to create patterns and
designs in the park.</p>
<h3 class="open-sans-700">Item Options</h3>
<p class="open-sans-500">Pick items such as trees, flowers, benches, and paths to add detail and interest to
your park design.</p>
<h3 class="open-sans-700">Remove Tile or Item</h3>
<p class="open-sans-500">To remove a tile or item from a cell, click the cell and select the empty option in
the tile or item options.</p>
<h3 class="open-sans-700">Lock Tile or Item</h3>
<p class="open-sans-500">To lock a tile or item in a cell, click the cell and select the lock option in the
tile or item options. This will prevent the tile or item from being changed during generation.</p>
<h3 class="open-sans-700">Reset Tile or Item</h3>
<p class="open-sans-500">To reset a tile or item in a cell, click the cell and select the reset option in the
tile or item options. This will reset the tile or item to its default state.</p>
</div>
</div>
</div>
<div class="footer">
<h1 class="bungee">Urban Park Design<br>
Using Wave Function Collapse</h1>
<h2 class="open-sans-500">This program is an interactive tool for designing urban parks. You can create maps using
various tiles and items, such as trees, flowers, and paths. As you select and place these elements, the tool
shows only the options that fit well together, ensuring your design is cohesive. It's easy to use, allowing you
to customize and experiment with park layouts directly on the website. This makes it ideal for planning and
visualizing urban park designs effectively.
</h2>
<h2 class="open-sans-500">
You are invited to fill in the feedback form to share your thoughts on the Urban Park Design Tool. Your feedback
is invaluable in understanding the impact of the tool on urban park design. By sharing your insights and
suggestions, you contribute to assessing and enhancing its effectiveness in real-world applications. Your
participation in this process is greatly appreciated. Thank you for helping to improve the impact of this
innovative tool!
</h2>
<h2 class="open-sans-500">
<a target="_blank" href="https://forms.gle/DJDFybWh9nHbjx8r8">Feedback Form</a>
</h2>
</div>
<script src="cell.js"></script>
<script src="tile.js"></script>
<script src="sketch.js"></script>
<script>
document.addEventListener("DOMContentLoaded", () => {
if (jsonOptions && jsonOptions.options && jsonOptions.options.types && jsonOptions.options.seasons) {
initializeTypeOptions();
initializeSeasonOptions();
initializeCategoryOptions();
} else {
setTimeout(() => {
initializeTypeOptions();
initializeSeasonOptions();
initializeCategoryOptions();
}, 1000); // Adjust the delay as needed
}
});
function resetEntireGrid() {
applyOptions();
initializeGrid();
resetGrid();
}
function resetFunction() {
applyOptions();
resetGrid();
}
function emptyGrid() {
applyOptions();
resetGrid();
grid.forEach((cell, index) => {
grid[index] = new Cell(cell.position, [tiles[0]], [items[0]]);
});
}
function initializeTypeOptions() {
let typesContainer = document.getElementById('types');
typesContainer.innerHTML = '';
jsonOptions.options.types.forEach(type => {
let typeOption = document.createElement('label');
typeOption.className = 'option-input';
let input = document.createElement('input');
input.type = 'checkbox';
input.checked = type.used;
let image = document.createElement('img');
image.src = imageToDataURL(cropImage(type.image));
typeOption.appendChild(input);
typeOption.appendChild(image);
typesContainer.appendChild(typeOption);
})
}
function initializeSeasonOptions() {
let seasonsContainer = document.getElementById('seasons');
seasonsContainer.innerHTML = '';
jsonOptions.options.seasons.forEach(type => {
let seasonOption = document.createElement('label');
seasonOption.className = 'option-input';
let input = document.createElement('input');
input.type = 'checkbox';
input.checked = type.used;
let image = document.createElement('img');
image.src = imageToDataURL(cropImage(type.image, 0, -TILE_HEIGHT * 1.25, TILE_WIDTH, TILE_HEIGHT * 2.5));
seasonOption.appendChild(input);
seasonOption.appendChild(image);
seasonsContainer.appendChild(seasonOption);
});
}
function initializeCategoryOptions() {
let categoriesContainer = document.getElementById('categories');
categoriesContainer.innerHTML = '';
jsonOptions.options.categories.forEach(category => {
let categoryOption = document.createElement('label');
categoryOption.className = 'option-input';
let input = document.createElement('input');
input.type = 'checkbox';
input.checked = category.used;
let image = document.createElement('img');
image.src = imageToDataURL(cropImage(category.image, 0, -TILE_HEIGHT / 2));
categoryOption.appendChild(input);
categoryOption.appendChild(image);
categoriesContainer.appendChild(categoryOption);
});
}
function applyOptions() {
// Update the types options
const inputs = document.querySelectorAll('.types input');
inputs.forEach((input, index) => {
// // Release the tiles that are being unchecked
grid.forEach(cell => {
if (cell.locked) {
if (cell.tileOptions[0].types === jsonOptions.options.types[index].name && !input.checked) {
cell.locked = false;
cell.removed = false;
}
}
})
jsonOptions.options.types[index].used = input.checked;
});
jsonOptions.options.types.forEach((type, index) => {
type.used = jsonOptions.options.types[index].used;
});
// Update the seasons options
const seasonInputs = document.querySelectorAll('.seasons input');
seasonInputs.forEach((input, index) => {
jsonOptions.options.seasons[index].used = input.checked;
});
jsonOptions.options.seasons.forEach((season, index) => {
season.used = jsonOptions.options.seasons[index].used;
});
// Update the categories options
const categoryInputs = document.querySelectorAll('.categories input');
categoryInputs.forEach((input, index) => {
jsonOptions.options.categories[index].used = input.checked;
});
jsonOptions.options.categories.forEach((category, index) => {
category.used = jsonOptions.options.categories[index].used;
});
}
function addOption(parentId, id, imagePath, onclick, tooltipText) {
const options = document.getElementById(parentId);
const option = document.createElement('div');
option.id = id;
option.onclick = onclick;
option.className = 'tooltip';
if (tooltipText) {
const tooltip = document.createElement('span');
tooltip.className = 'tooltip-text open-sans-500';
tooltip.innerText = tooltipText;
option.appendChild(tooltip);
}
const optionImg = document.createElement('img');
optionImg.src = imagePath;
option.appendChild(optionImg);
options.appendChild(option);
}
// Get the modal
const modal = document.getElementById("myModal");
// Get the button that opens the modal
const btn = document.getElementById("myBtn");
// Get the <span> element that closes the modal
const span = document.getElementsByClassName("close")[0];
// When the user clicks the button, open the modal
btn.onclick = function () {
modal.style.display = "flex";
}
// When the user clicks on <span> (x), close the modal
span.onclick = function () {
modal.style.display = "none";
}
// When the user clicks anywhere outside of the modal, close it
window.onclick = function (event) {
if (event.target === modal) {
modal.style.display = "none";
}
}
</script>
</body>
</html>