tangled
alpha
login
or
join now
vielle.dev
/
site-archive
0
fork
atom
[Archived] Archived WIP of vielle.dev
0
fork
atom
overview
issues
pulls
pipelines
Scatter clouds in the sky
vielle.dev
9 months ago
88c48198
e7c2a49a
+41
-13
2 changed files
expand all
collapse all
unified
split
src
components
blog
background
Cloud.astro
config.ts
+39
-12
src/components/blog/background/Cloud.astro
···
1
1
---
2
2
import { blog } from "@/config";
3
3
-
4
4
-
const { width, height, count } = blog.background.clouds;
5
3
---
6
4
7
5
<style>
8
6
img {
9
7
position: absolute;
10
10
-
top: 20rem;
11
8
}
12
9
</style>
13
10
14
11
{
15
15
-
new Array(count).fill(0).map((_) => (
16
16
-
<img
17
17
-
src="https://cdn.zmescience.com/wp-content/uploads/2017/07/8690313402_5f76f736b3_k-1-1024x683.webp"
18
18
-
alt=""
19
19
-
style={`--parallax-speed: ${blog.background.parallax.clouds};
12
12
+
new Array(blog.background.clouds.count).fill(0).reduce(
13
13
+
(prev) => {
14
14
+
const width =
15
15
+
blog.background.clouds.width[0] +
16
16
+
(blog.background.clouds.width[1] - blog.background.clouds.width[0]) *
17
17
+
Math.random(),
18
18
+
height =
19
19
+
blog.background.clouds.height[0] +
20
20
+
(blog.background.clouds.height[1] -
21
21
+
blog.background.clouds.height[0]) *
22
22
+
Math.random(),
23
23
+
x = Math.random(),
24
24
+
y =
25
25
+
prev.y +
26
26
+
blog.background.clouds.yGap[0] +
27
27
+
Math.random() *
28
28
+
(blog.background.clouds.yGap[1] - blog.background.clouds.yGap[0]);
29
29
+
30
30
+
return {
31
31
+
y: y,
32
32
+
output: [
33
33
+
...prev.output,
34
34
+
<img
35
35
+
src="https://cdn.zmescience.com/wp-content/uploads/2017/07/8690313402_5f76f736b3_k-1-1024x683.webp"
36
36
+
alt=""
37
37
+
style={`--parallax-speed: ${blog.background.parallax.clouds};
20
38
21
21
-
width: ${width[0] + (width[1] - width[0]) * Math.random()}rem;
22
22
-
height: ${height[0] + (height[1] - height[0]) * Math.random()}rem;`}
23
23
-
/>
24
24
-
))
39
39
+
width: ${width}rem;
40
40
+
height: ${height}rem;
41
41
+
top: ${y}rem;
42
42
+
left: calc(${x} * 200lvw - 100lvw);`}
43
43
+
/>,
44
44
+
],
45
45
+
};
46
46
+
},
47
47
+
{
48
48
+
y: 0,
49
49
+
output: [],
50
50
+
}
51
51
+
).output
25
52
}
+2
-1
src/config.ts
···
15
15
clouds: 50,
16
16
},
17
17
clouds: {
18
18
-
count: 40,
18
18
+
count: 8,
19
19
width: [40, 80],
20
20
height: [15, 30],
21
21
+
yGap: [15, 25]
21
22
},
22
23
},
23
24
};