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
Make sun spinning SVG
vielle.dev
9 months ago
7e0550fd
eea92572
+33
-7
2 changed files
expand all
collapse all
unified
split
src
components
blog
background
Sun.astro
config.ts
+27
-6
src/components/blog/background/Sun.astro
···
1
1
---
2
2
-
import { blog } from "@/config";
2
2
+
import { blog, utils } from "@/config";
3
3
4
4
interface Props {
5
5
percent: number;
6
6
}
7
7
8
8
const { percent } = Astro.props;
9
9
+
const prongs = Math.round(utils.getRandom(blog.background.sun.prongs));
9
10
---
10
11
11
12
<style>
12
12
-
img {
13
13
+
svg {
13
14
position: absolute;
14
15
border-radius: 100%;
15
16
top: 15rem;
16
17
left: calc(100lvw * var(--sun-progress-percent) - 7.5rem);
17
18
z-index: -1;
18
19
20
20
+
animation:
21
21
+
1ms alternate scroll,
22
22
+
normal 120s infinite linear spin !important;
23
23
+
animation-timeline: scroll(), auto !important;
19
24
}
20
25
</style>
21
26
22
22
-
<img
27
27
+
<svg
23
28
id="sun"
24
24
-
src="https://upload.wikimedia.org/wikipedia/commons/thumb/6/67/BBSO_full-disk_H-alpha_2002-07-26_153931_color.png/250px-BBSO_full-disk_H-alpha_2002-07-26_153931_color.png"
25
25
-
alt=""
29
29
+
width="300"
30
30
+
height="300"
31
31
+
viewBox="0 0 100 100"
26
32
style={`--parallax-speed: ${blog.background.parallax.sun};
27
33
--sun-progress-percent: ${percent}`}
28
34
data-parallax
29
29
-
/>
35
35
+
>
36
36
+
<circle style="fill:#ffff00" cx="50" cy="50" r="35"></circle>
37
37
+
38
38
+
{
39
39
+
new Array(prongs)
40
40
+
.fill(0)
41
41
+
.map((_, i) => (
42
42
+
<polygon
43
43
+
fill="#ffff00"
44
44
+
points="50 0, 55 10, 45 10"
45
45
+
transform={`rotate(${(i / prongs) * 360})`}
46
46
+
transform-origin="center"
47
47
+
/>
48
48
+
))
49
49
+
}
50
50
+
</svg>
+6
-1
src/config.ts
···
14
14
moon: 20,
15
15
star: [0, 5],
16
16
},
17
17
+
17
18
clouds: {
18
19
count: 8,
19
20
width: [40, 80],
···
27
28
prongs: [4, 8],
28
29
rotateSpeed: [20, 40],
29
30
},
31
31
+
32
32
+
sun: {
33
33
+
prongs: [10, 20],
34
34
+
},
30
35
},
31
36
} as const;
32
37
···
35
40
variance: [number, number] | readonly [number, number],
36
41
seed?: number
37
42
) {
38
38
-
return variance[0] + (seed ?? Math.random()) * variance[1] - variance[0];
43
43
+
return variance[0] + (seed ?? Math.random()) * (variance[1] - variance[0]);
39
44
},
40
45
};