-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathart_6.html
250 lines (216 loc) · 8.33 KB
/
art_6.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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<script>
var firstSymbol = Symbol('stepOne')
var secondSymbol = Symbol('kn_2')
var stop = false
</script>
<title>Art</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- <link rel="stylesheet" type="text/css" media="screen" href="main.css"> -->
<script src="main.js"></script>
<style>
svg {
width: 50%;height: 50%;
stroke: rgb(114,212,114);
fill: black;
fill-opacity: 0.6;
stroke-width: 2px;
}
body {
background-color: #122
}
#behind {
stroke: cyan;
fill: none;
stroke: black;
}
</style>
</head>
<body>
<svg id="aeonKNight" viewBox="-200 -200 400 400">
<!-- <text id="i" x="0" y="0" fill="red">10</text> -->
<defs>
<radialGradient id="grad1" cx="50%" cy="50%" r="50%" fx="50%" fy="50%">
<stop offset="0%" style="stop-color:lime;stop-opacity:1" />
<stop offset="1%" style="stop-color:#fff;stop-opacity:1" />
<stop offset="10%" style="stop-color:rgb(0,0,0);stop-opacity:1" />
<stop offset="70%" style="stop-color:lime;stop-opacity:0.3" />
<stop offset="80%" style="stop-color:lime;stop-opacity:0.9" />
<stop offset="95%" style="stop-color:rgb(255,255,255);stop-opacity:0.8" />
<stop offset="100%" style="stop-color:lime;stop-opacity:0.7" />
</radialGradient>
</defs>
<!--
<ellipse stroke-width="0" cx="0" cy="0" rx="100" ry="100" fill="url(#grad1)" />
<polyline id="behind" points="25,0 123.38,123.38 0,25 -123.38,123.38 -25,0 -123.38,-123.38 0,-25 123.38,-123.38 25,0 50,0 105.75,105.75 0,50 -105.75,105.75 -50,0 -105.75,-105.75 0,-50 105.75,-105.75 50,0 75,0 88.13,88.13 0,75 -88.13,88.13 -75,0 -88.13,-88.13 0,-75 88.13,-88.13 75,0 100,0 70.5,70.5 0,100 -70.5,70.5 -100,0 -70.5,-70.5 0,-100 70.5,-70.5 100,0 125,0 52.88,52.88 0,125 -52.88,52.88 -125,0 -52.88,-52.88 0,-125 52.88,-52.88 125,0 150,0 35.25,35.25 0,150 -35.25,35.25 -150,0 -35.25,-35.25 0,-150 35.25,-35.25 150,0 175,0 17.63,17.63 0,175 -17.63,17.63 -175,0 -17.63,-17.63 0,-175 17.63,-17.63 175,0 "
/> -->
<polyline id="KN_poly" points="25,0 123.38,123.38 0,25 -123.38,123.38 -25,0 -123.38,-123.38 0,-25 123.38,-123.38 25,0 50,0 105.75,105.75 0,50 -105.75,105.75 -50,0 -105.75,-105.75 0,-50 105.75,-105.75 50,0 75,0 88.13,88.13 0,75 -88.13,88.13 -75,0 -88.13,-88.13 0,-75 88.13,-88.13 75,0 100,0 70.5,70.5 0,100 -70.5,70.5 -100,0 -70.5,-70.5 0,-100 70.5,-70.5 100,0 125,0 52.88,52.88 0,125 -52.88,52.88 -125,0 -52.88,-52.88 0,-125 52.88,-52.88 125,0 150,0 35.25,35.25 0,150 -35.25,35.25 -150,0 -35.25,-35.25 0,-150 35.25,-35.25 150,0 175,0 17.63,17.63 0,175 -17.63,17.63 -175,0 -17.63,-17.63 0,-175 17.63,-17.63 175,0 "
/>
<polyline style="display:none;" id="kn_2" points="
150,0 50,0 0,150 -50,0
0,-150 50,0 100,0 0,100
-100,0 0,-100 100,0 150,0
0,50 -150,0 0,-50 150,0"/>
<circle id="pos" cy="0" cx="0" r="12.5" fill="url(#grad1)" />
</svg>
<form
style="display:none; flex; justify-content: center; flex-direction: column; width: 50%; "
>
<input id="handleDuration" oninput="setDuration(this.value)"
style="width: 100%;"
type="range"
min="0" max="150"
value="500"
>
/>
<input id="ms" style="width: 130px;"
value="0"
/>
<script>
// document.getElementById('handleDuration').setAttribute('max', l)
duration = {ms: document.getElementById('handleDuration'.value) }
function setDuration(event) {
duration.ms = event * 10
document.getElementById('ms').setAttribute('value', `${duration.ms}ms ${duration.ms / 1000}s ${(1/ (duration.ms / 1000)) * 60 |0}bpm`)
}
</script>
</form>
<script>aeonKNight = document.getElementById("aeonKNight")</script>
<script>/* DEV
*/
cl = console.log
updateI = () => document.getElementById('i').innerHTML = i
sP= (element) => (prop, value) => element.style.setProperty(prop, value)
/*
*/</script>
<script>
function appendStyle(createTextNode) {
let style = document.createElement("style");
style.appendChild(document.createTextNode(createTextNode));
document.head.appendChild(style);
return style.sheet;
};
</script>
<script>
points = {
[firstSymbol]: Array.from(document.getElementById("KN_poly").points),
[secondSymbol]: Array.from(document.getElementById("kn_2").points),
}
polys = {
[firstSymbol]: document.getElementById("KN_poly"),
[secondSymbol]: document.getElementById("kn_2"),
}
</script>
<script>
//untested
stepCB = (rate,cb) =>{
let id=0
let start=null
function next(timestamp, rate, cb) {
progress = timestamp - start;
if(id%rate==0){
id = wrAF(timestamp => {
cb()
next(timestamp, rate)
})
}
}
next(start)
}
</script>
<script>
pos = document.getElementById("pos")
p = polys[firstSymbol].points
l = p.length
ptl = polys[firstSymbol].getTotalLength()
wrAF = window.requestAnimationFrame
// void appendStyle(`svg { opacity: 0.6;stroke-dasharray: ${ptl}; stroke-dashoffset: ${ptl/4};}`)
function shift(symbol) {
p = polys[symbol].points
l = p.length
np = Array.from(points[symbol])
let wow = np.splice(i%l-1,l).concat(np).reduce((a,{x,y}) => a.concat([x,y]), [] )
double = n => n*2
adding = ( i%(l*2) <= i%l )
gap = ( adding ) ? l-i%l : i%l
gap = 2
// cl(i%(l*2), i%l, i%(l*2) <= i%l )
let a = wow.splice(0, (double(l))-double(gap));
// polys[symbol].setAttribute('points', (a).toString()
// )
// cl(wow)
if( a.length ){
pos.setAttribute(('cx'), a[0]|0)
pos.setAttribute(('cy'), a[1]|0)
// !adding ? (
// pos.setAttribute(('cx'), a[0]|0),
// pos.setAttribute(('cy'), a[1]|0)
// ):(
// pos.setAttribute(('cx'), a[a.length - 2]|0),
// pos.setAttribute(('cy'), a[a.length - 1]|0))
// cl( a )
}
}
i = 0
spins=1 * l
function up(fn){ if(i>=spins )i=0;
/* */if(stop){clearTimeout(cT);return;};
i++; fn(); cT = setTimeout(() => up(fn), 700)
}
// up(shift)
/* *options: <>arrayOf([ dur: ms, repeat: bool ]) *currentId:
effectTimingSwitch */
var start = null;
id=0
const effectTimingSwitch = (options, currentId) => {
options.forEach(({ frames, cb }) => {
if ( 0 === (currentId%frames) ) {
cb()
}
})
}
/* */
function step(timestamp, options={dur: 2000, repeat: true}) {
// cl(options)
// cl(id, 360%id)
if (!start) start = timestamp;
var progress = timestamp - start;
// cl(id, progress)
if(id%4==0){
// sP(aeonKNight)('transform', `rotate(${id%360}deg)`)
}
effectTimingSwitch([
{ frames: 16, cb:() => (i++,shift(firstSymbol)) },
// { frames: 1, cb:() => (i++,shift(secondSymbol)) },
], id)
// if(id%6==0)
// {
// (i++,shift())
// // color=`rgb(${[id%126|0,id%256|0,id%126|0].join()})`
// // sP(aeonKNight)('stroke', color)
// }
if ((progress < options.dur || options.repeat) && stop!==true ) {
id = wrAF(t => step(t, options))
}else{cl('done');stop=true}
}
const withProps = props => () => {
wrAF(timestamp => step(timestamp, props))
}
// wrAF(step);
withProps({dur: 10000, repeat: true})()
</script>
</body>
</html>
<!-- points="0,0 141,141 0,0 -141,141 0,0 -141,-141 0,0 141,-141 0,0 25,0 123.38,123.38 0,25 -123.38,123.38 -25,0 -123.38,-123.38 0,-25 123.38,-123.38 25,0 50,0 105.75,105.75 0,50 -105.75,105.75 -50,0 -105.75,-105.75 0,-50 105.75,-105.75 50,0 75,0 88.13,88.13 0,75 -88.13,88.13 -75,0 -88.13,-88.13 0,-75 88.13,-88.13 75,0 100,0 70.5,70.5 0,100 -70.5,70.5 -100,0 -70.5,-70.5 0,-100 70.5,-70.5 100,0 125,0 52.88,52.88 0,125 -52.88,52.88 -125,0 -52.88,-52.88 0,-125 52.88,-52.88 125,0 150,0 35.25,35.25 0,150 -35.25,35.25 -150,0 -35.25,-35.25 0,-150 35.25,-35.25 150,0 175,0 17.63,17.63 0,175 -17.63,17.63 -175,0 -17.63,-17.63 0,-175 17.63,-17.63 175,0" -->
<!--
points= "
50,0 0,150 -50,0
0,-150 50,0 100,0 0,100
-100,0 0,-100 100,0 150,0
0,50 -150,0 0,-50 150,0" -->
<!-- 200,0
0,0 -200,0 0,0 200,0`" -->