-
Notifications
You must be signed in to change notification settings - Fork 0
/
dayNightPicture.html
131 lines (120 loc) · 3.37 KB
/
dayNightPicture.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style type="text/css">
figure {
display: grid;
border-radius: 1rem;
overflow: hidden;
cursor: pointer;
}
figure > * {
grid-area: 1/1;
transition: .4s;
}
figure figcaption {
display: grid;
align-items: end;
font-family: sans-serif;
font-size: 2.3rem;
font-weight: bold;
color: #0000;
padding: .75rem;
background: var(--c, #0009);
clip-path: inset(0 var(--_i, 100%) 0 0);
-webkit-mask: linear-gradient(#000 0 0),
linear-gradient(#000 0 0);
-webkit-mask-composite: xor;
-webkit-mask-clip: text, padding-box;
}
figure:hover figcaption {
--_i: 0%;
}
figure:hover img {
transform: scale(1.2);
}
@supports not (-webkit-mask-clip: text) {
figure figcaption {
-webkit-mask: none;
color: #fff;
}
}
body {
margin: 0;
min-height: 100vh;
display: grid;
grid-auto-flow: column;
place-content: center;
background: #425a52;
}
</style>
<script>
function setup() {
pixelDensity(1);
createCanvas();
colorMode(HSB, 1, 1, 1);
windowResized();
}
let gw, gh;
let c1, offset;
let updatesPerFrame;
let xSpan = 15;
let ySpan = xSpan * 1.5;
let init = () => {
gw = floor(width / xSpan) + 1;
gh = floor(height / ySpan) + 1;
updatesPerFrame = gw * gh * 0.025;
c1 = createGraphics(gw * xSpan, gh * ySpan);
c1.colorMode(HSB, 1, 1, 1);
c1.textAlign(LEFT, TOP);
c1.background(0);
c1.textSize(xSpan * 1.5);
offset = 0;
};
function draw() {
background(0);
offset += 1;
c1.noStroke();
for (let i = 0; i < updatesPerFrame; i++) {
let x = floor(random(gw));
let y = floor(random(gh));
c1.fill(0);
c1.rect(x * xSpan, y * ySpan, xSpan, ySpan);
c1.fill(0.33 + random(-0.1, 0.1), random(), random(0.5, 1));
c1.text(floor(random(2)), x * xSpan, y * ySpan);
}
for (let i = 0; i < height; i++) {
let w = i;
image(
c1,
-w / 2,
i,
width + w,
1,
0,
(i + offset) % (gh * ySpan),
gw * xSpan,
1
);
}
}
function windowResized() {
resizeCanvas(windowWidth, windowHeight);
init();
}
</script>
</head>
<body>
<figure>
<img src="https://picsum.photos/id/287/250/300" alt="Mountains">
<figcaption>The Day</figcaption>
</figure>
<figure style="--c:#fff5">
<img src="https://picsum.photos/id/475/250/300" alt="Mountains">
<figcaption>The Night</figcaption>
</figure>
</div>
</body>
</html>