-
Notifications
You must be signed in to change notification settings - Fork 0
/
gen.py
68 lines (64 loc) · 1.82 KB
/
gen.py
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
from pathlib import Path
import random
dirs = "Curated", "PSI 0.5", "PSI 1.0", "Real"
pathss = {name: random.sample(list(Path(name).iterdir()), 100) for name in dirs}
print("""
<html>
<head>
<style>
body {
margin: 0;
}
.choices {
flex-direction: row;
justify-content: center;
align-items: center;
display: flex;
min-width: 4096px;
}
.choice-name {
width: 100%;
text-align: center;
visibility: hidden;
margin: 0;
font-size: 4em;
}
.choices:active .choice-name {
visibility: visible;
}
.choice-img {
width: 1024px;
height: 1024px;
}
</style>
<script>
window.onload = function() {
function observe(elems) {
for (elem of elems) {
if (elem.isIntersecting) {
elem.target.setAttribute("src", elem.target.getAttribute("data-src"));
}
}
}
const imageObserver = new IntersectionObserver(observe, {"threshold": 0});
for (elem of document.getElementsByClassName("choice-img")) {
console.log(elem);
imageObserver.observe(elem);
}
}
</script>
</head>
<body>
""")
for _ in range(100):
puzzle = [(kind, paths.pop()) for kind, paths in pathss.items()]
random.shuffle(puzzle)
print(""" <div class="choices">""")
img = """ <div class="choice"><img class="choice-img" data-src="{path}" loading="lazy" /><p class="choice-name">{choice}</p></div>"""
for choice, path in puzzle:
print(img.format(choice=choice, path=path))
print(" </div>")
print("""
</body>
</html>
""")