-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgen_cropped.py
81 lines (77 loc) · 2.17 KB
/
gen_cropped.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
69
70
71
72
73
74
75
76
77
78
79
80
81
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: 1800px;
}
.choice-name {
width: 100%;
text-align: center;
visibility: hidden;
margin: 0;
font-size: 4em;
}
.choices:active .choice-name {
visibility: visible;
}
.choice-img-shift {
margin-top: -50px;
}
.choice-img-wrapper {
width: 450px;
height: 600px;
overflow: hidden;
display: flex;
align-items: center;
justify-content: center;
}
</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">
<div class="choice-img-wrapper"><div class="choice-img-shift">
<img class="choice-img" data-src="{path}" width="1024" height="1024" />
</div></div>
<p class="choice-name">{choice}</p>
</div>"""
for choice, path in puzzle:
print(img.format(choice=choice, path=path))
print(" </div>")
print("""
</body>
</html>
""")