generated from argyleink/shortstack
-
Notifications
You must be signed in to change notification settings - Fork 402
/
Copy pathindex.js
32 lines (26 loc) · 806 Bytes
/
index.js
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
function glitchyPaths() {
document.querySelector('pre').textContent = `
@keyframes cyberpunk-glitch {
0% { clip-path: polygon(${punkyPolygons()}); }
4% { clip-path: polygon(${punkyPolygons()}); }
27% { clip-path: polygon(${punkyPolygons()}); }
51% { clip-path: polygon(${punkyPolygons()}); }
66% { clip-path: polygon(${punkyPolygons()}); }
91% { clip-path: polygon(${punkyPolygons()}); }
1%, 5%, 28%, 53%, 67%, 92% {
clip-path: none;
}
}
`.trim()
}
function punkyPolygons() {
const collection = new Set()
for (let i = 0; i <= 25; i++)
collection.add(`${rando()}% ${rando()}%`)
return Array.from(collection.values()).join(',')
}
function rando() {
return (Math.random() * 100).toFixed()
}
glitchyPaths()
document.querySelector('button').onclick = glitchyPaths