-
Notifications
You must be signed in to change notification settings - Fork 0
/
all.html
334 lines (323 loc) · 15.1 KB
/
all.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
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
<!DOCTYPE html>
<html lang="ru" style="width: 100%;height:100%;background:rgb(34,34,36);font-family: 'Open Sans', sans-serif;">
<head>
<meta charset="UTF-8">
<title>Сайт-портфолио Ценекова Дмитрия</title>
<link rel="icon" type="image/png" sizes="32x32" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAADqUExURUdwTIF3XoNzRW9mRnVpQ4FyRHNoR15ZQ4d2ToR0RYRzRod9ZIR0RYV0R4+FaGBXPn9ySIV2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=800, initial-scale=1.0">
<meta content='true' name='HandheldFriendly'/>
<meta content='800' name='MobileOptimized'/>
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="description" content="Проекты Ценекова Дмитрия">
<meta name="keywords" content="Ценеков Дмитрий, Проекты, Сайт-портфолио">
<meta name="author" content="dim0n4eg">
<meta http-equiv="Cache-Control" content="public, max-age=86400">
<script type="text/javascript">
function constrain(a,b,c){return Math.min(Math.max(a,b),c)}
// (вход, установка, п, и, д, период в секундах, мин.выход, макс. выход)
var PIDdata=[];
function computePID(input, setpoint, kp, ki, kd, dt, minOut, maxOut, num) {
var err = setpoint - input;
if (PIDdata[num]==undefined)
PIDdata[num]=[0,0];
var integral = PIDdata[num][0], prevErr = PIDdata[num][1];
integral = constrain(integral + err * dt * ki, minOut, maxOut);
PIDdata[num][0] = integral;
var D = (err - prevErr) / dt;
PIDdata[num][0] = err;
return constrain(err * kp + integral + D * kd, minOut, maxOut);
}
function getPosition(e) {
var rect = e.target.getBoundingClientRect();
var x = -1;
var y = -1;
if ((e.clientX != undefined) && (e.clientX != undefined)) {
x = e.clientX - rect.left;
y = e.clientY - rect.top;
} else
if (e.touches != undefined)
if (e.touches.length > 0) {
x = e.touches[0].clientX - rect.left;
y = e.touches[0].clientY - rect.top;
} else if (e.changedTouches.length > 0) {
x = e.changedTouches[0].clientX - rect.left;
y = e.changedTouches[0].clientY - rect.top;
}
x=Math.round(x);
y=Math.round(y);
return (x + ':' + y);
}
function roundRect(ctx, x1, y1, x2, y2, radius) {
radius = Math.min(radius, (x2 - x1) / 2, (y2 - y1) / 2); // избегаем артефактов, в случае если радиус скругления больше одной из сторон
ctx.beginPath();
ctx.moveTo(x1 + radius, y1);
ctx.lineTo(x2 - radius, y1);
ctx.arcTo(x2, y1, x2, y1 + radius, radius);
ctx.lineTo(x2, y2 - radius);
ctx.arcTo(x2, y2, x2 - radius, y2, radius);
ctx.lineTo(x1 + radius, y2);
ctx.arcTo(x1, y2, x1, y2 - radius, radius);
ctx.lineTo(x1, y1 + radius);
ctx.arcTo(x1, y1, x1 + radius, y1, radius);
ctx.fill();
ctx.stroke();
}
function containPoint(tX,tY,tW,tH,x, y) {
return tX <= x && x <= tX + tW && tY <= y && y <= tY + tH;
}
function colorChannelMixer(colorChannelA, colorChannelB, amountToMix){
var channelA = colorChannelA*amountToMix;
var channelB = colorChannelB*(1-amountToMix);
return parseInt(channelA+channelB);
}
function colorMixer(rgbA, rgbB, amountToMix){
var r = colorChannelMixer(rgbA[0],rgbB[0],amountToMix);
var g = colorChannelMixer(rgbA[1],rgbB[1],amountToMix);
var b = colorChannelMixer(rgbA[2],rgbB[2],amountToMix);
return "rgb("+r+","+g+","+b+")";
}
var _errors=[];function copyToClipboard(text){if(window.clipboardData&&window.clipboardData.setData){return window.clipboardData.setData("Text",text);}
else if(document.queryCommandSupported&&document.queryCommandSupported("copy")){var textarea=document.createElement("textarea");textarea.textContent=text;textarea.style.position="fixed";document.body.appendChild(textarea);textarea.select();try{return document.execCommand("copy");}
catch(ex){console.warn("Copy to clipboard failed.",ex);return prompt("Copy to clipboard: Ctrl+C, Enter",text);}
finally{document.body.removeChild(textarea);}}}
function _onerror(e,e2)
{if(_errors.length==0)
setTimeout(function(){alert(JSON.stringify(_errors));copyToClipboard(JSON.stringify(_errors));},1500);_errors.push([e,e2]);}
window.onerror=function(){_onerror(Array.prototype.slice.call(arguments).join('; '),'window.onerror')};
var buttons=[];
var cacheCanvas={};
function drawButton(ctx,x,y,h,w,v,style,num){
if (num==0) Object.keys(cacheCanvas).filter((x)=>new Date - cacheCanvas[x][1]>2000).forEach((x)=>{delete cacheCanvas[x];});
switch(style) {
case 1:
var s='sty:'+style+';h:'+Math.floor(h)+';w:'+Math.floor(w)+';v:'+Math.floor(v*1000);
if (cacheCanvas[s]===undefined){
cacheCanvas[s] = [document.createElement('canvas'),0];
cacheCanvas[s][0].width = h*3;
cacheCanvas[s][0].height = w*4;
var _old=[ctx,x,y]
var ctx = cacheCanvas[s][0].getContext("2d");
x=h;
y=w*2;
var gradient = ctx.createLinearGradient(x,0, x+h,0);
gradient.addColorStop(0, '#AAA');
gradient.addColorStop(.1, colorMixer([221,221,221],[221,170,170],1-constrain(v,0,1)));
gradient.addColorStop(.9, colorMixer([221,221,221],[221,170,170],1-constrain(v,0,1)));
gradient.addColorStop(1, colorMixer([187,187,187],[187,119,119],1-constrain(v,0,1)));
ctx.fillStyle = "#000000";
ctx.strokeStyle = gradient;
ctx.lineWidth = 15;
roundRect(ctx,x,y,x+h,y+w,8);
gradient = ctx.createLinearGradient(x,0, x+h,0);
gradient.addColorStop(0, '#400');
gradient.addColorStop(.03, '#800');
gradient.addColorStop(.97, '#800');
gradient.addColorStop(1, '#400');
ctx.fillStyle = gradient;
ctx.strokeStyle = gradient;
ctx.lineWidth = 1;
roundRect(ctx,x,y-w*v*0.7,x+h,y+w,8);
gradient = ctx.createLinearGradient(x,0, x+h,0);
gradient.addColorStop(0, '#B00');
gradient.addColorStop(.8, '#F00');
gradient.addColorStop(1, '#B00');
ctx.fillStyle = gradient;
ctx.strokeStyle = "#D00";
ctx.lineWidth = 3;
roundRect(ctx,x,y-w*v,x+h,y+w-w*v*0.7,14);
ctx=_old[0];
x=_old[1];
y=_old[2];
}
cacheCanvas[s][1]=new Date;
ctx.drawImage(cacheCanvas[s][0], x-1*h, y-2*w);
ctx.textAlign = 'center';
ctx.textBaseline = 'middle';
ctx.font = Math.floor(w*0.3)+'px Arial';
for (var i=4;i>=0;i-=1){
ctx.fillStyle = 'hsl(25,100%,'+(70-4*i)+'%)';
ctx.fillText(hitboxs[num][8], x+h/2+i/9,y+w/2-w*v+i);
}
hitboxs[num][0]=x;
hitboxs[num][1]=y-w*1;
hitboxs[num][2]=h;
hitboxs[num][3]=w+w*1;
while (hitboxs[num][7].length<4)
hitboxs[num][7].push(computePID(hitboxs[num][4],hitboxs[num][5]+0.01*Math.sin((new Date)/300),0.1,0.1,0.1,1,-2,2,num));
hitboxs[num][4]=constrain(hitboxs[num][4]+hitboxs[num][7].shift()/8,0.1,2);
var e=hitboxs[num];
if (hitboxs[num][5]>0.5 && (new Date)-hitboxs[num][6]>50 || !containPoint(e[0],e[1],e[2],e[3],mouselastX,mouselastY))
hitboxs[num][5]=1;
break;
case 2:
var s='sty:'+style+';h:'+Math.floor(h)+';w:'+Math.floor(w)+';v:'+Math.floor(v*50);
if (cacheCanvas[s]===undefined){
cacheCanvas[s] = [document.createElement('canvas'),0];
cacheCanvas[s][0].width = h*3;
cacheCanvas[s][0].height = w*4;
var _old=[ctx,x,y]
var ctx = cacheCanvas[s][0].getContext("2d");
x=h;
y=w*2;
var gradient = ctx.createLinearGradient(0,y+w-w*v*0.7, 0,y+w);
gradient.addColorStop(0, 'hsl(199,92%,70%)');
//gradient.addColorStop(.03, '#800');
//gradient.addColorStop(.97, '#800');
gradient.addColorStop(1, 'hsl(199,92%,40%)');
ctx.fillStyle = gradient;
ctx.strokeStyle = gradient;
ctx.lineWidth = 1;
roundRect(ctx,x,y-w*v*0.7,x+h,y+w,20);
gradient = ctx.createLinearGradient(0,y-w*v, 0,y+w-w*v*0.7);
gradient.addColorStop(0, 'hsl(199,92%,70%)');
//gradient.addColorStop(.8, '#');
gradient.addColorStop(1, 'hsl(199,92%,50%)');
ctx.fillStyle = gradient;
ctx.strokeStyle = 'hsl(199,92%,60%)';
ctx.lineWidth = 2;
roundRect(ctx,x,y-w*v,x+h,y+w-w*v*0.7,20);
ctx=_old[0];
x=_old[1];
y=_old[2];
}
cacheCanvas[s][1]=new Date;
ctx.drawImage(cacheCanvas[s][0], x-1*h, y-2*w);
hitboxs[num][0]=x;
hitboxs[num][1]=y-w*1;
hitboxs[num][2]=h;
hitboxs[num][3]=w+w*1;
while (hitboxs[num][7].length<5)
hitboxs[num][7].push(computePID(hitboxs[num][4],hitboxs[num][5]+0.01*Math.sin((new Date)/300),0.05,0.05,0.05,1,-2,2,num));
hitboxs[num][4]=constrain(hitboxs[num][4]+hitboxs[num][7].shift()/8,0.1,2);
var e=hitboxs[num];
if (hitboxs[num][5]>0.5 && (new Date)-hitboxs[num][6]>50 || !containPoint(e[0],e[1],e[2],e[3],mouselastX,mouselastY))
hitboxs[num][5]=1;
break;
default:
console.log('drawButton error')
}
}
var canvas, ctx;
function onload(){
setTimeout(()=>{console.log('Created by dim0n4eg')},100);
canvas = document.getElementById('canvas');
ctx = canvas.getContext("2d", {alpha:false,antialias:false,depth:false,desynchronized:true});
render();
canvas.addEventListener('mousemove', mouseMove);
canvas.addEventListener("touchmove", mouseMove);
canvas.addEventListener('mousedown', mouseDown);
canvas.addEventListener("touchstart", mouseDown);
canvas.addEventListener('mouseup', mouseUp);
canvas.addEventListener("touchend", mouseUp);
canvas.addEventListener('mouseout', mouseUp);
canvas.addEventListener("touchcancel", mouseUp);
}
hitboxs=[[0,0,0,0,1,1,new Date,[],'English'],[0,0,0,0,1,1,new Date,[],'Русский']];
// 0.6 0.4
for (var i=0;i<40;i++)
{
var rnd=(()=>{return (Math.random()+Math.random()+Math.random())/3});
var x=0;
var y=0;
while (-.38<x && x<.38 && -.38<y && y<.38 || (hitboxs.filter((e,i)=>{return 2<=i && i<=41 && (x-e[8])**2+(y-e[9])**2<0.15**2}).length!=0)) {
x=rnd()*2-1;
y=rnd()*2-1;
}
hitboxs.push([0,0,0,0,1,1,new Date,[],x,y,new Date]);
}
var backgroundCanv=[0,0];
function render()
{
if (canvas.clientHeight != canvas.height || canvas.clientWidth != canvas.width) {
canvas.height = canvas.clientHeight;
canvas.width = canvas.clientWidth;
}
//ctx.fillStyle = "#4f51bf";
//ctx.fillRect(0, 0, canvas.width, canvas.height);
var cW = canvas.width, cH = canvas.height;
var mWH = Math.min(cW,cH);
if (backgroundCanv[0]!=cW || backgroundCanv[1]!=cH || backgroundCanv[2]==undefined)
{
backgroundCanv[0]=cW;
backgroundCanv[1]=cH;
backgroundCanv[2] = document.createElement('canvas');
backgroundCanv[2].width = backgroundCanv[0];
backgroundCanv[2].height = backgroundCanv[1];
var _ctx = backgroundCanv[2].getContext("2d");
var gradient = _ctx.createLinearGradient(0,0, cW, cH); for (var i=0;i<36;i++) gradient.addColorStop(i/36, 'hsl(199,92%,'+(35-4*i/10)+'%)');
_ctx.fillStyle = gradient;
_ctx.fillRect(0, 0, canvas.width, canvas.height);
for (var i=10;i>=0;i-=1){
gradient = _ctx.createLinearGradient(cW, cH, 0, 0); for (var j=0;j<36;j++) gradient.addColorStop(j/36, 'hsl(199,92%,'+(81-4*i-j*0.7)+'%)');
_ctx.fillStyle = gradient;
_ctx.strokeStyle = gradient;
roundRect(_ctx,cW/2-mWH*0.3+i/3,cH/2-mWH*0.2+3*i,cW/2+mWH*0.3+i/3,cH/2+mWH*0.2+3*i,8);
}
}
ctx.drawImage(backgroundCanv[2], 0, 0);
drawButton(ctx, cW/2-mWH*0.25, cH/2+mWH*0.071, mWH*0.2, mWH*0.2/2, hitboxs[0][4]/2, 1, 0);
drawButton(ctx, cW/2+mWH*0.05, cH/2+mWH*0.071, mWH*0.2, mWH*0.2/2, hitboxs[1][4]/2, 1, 1);
ctx.textAlign = 'center';
ctx.textBaseline = 'middle';
for (var i=8;i>=0;i-=1){
ctx.fillStyle = 'hsl(25,100%,'+(70-4*i)+'%)';
ctx.font = Math.floor(mWH*0.08)+'px Arial';
ctx.fillText("Выберите язык", cW/2+i/9, cH/2-mWH*0.14+1*i);
ctx.font = Math.floor(mWH*0.04)+'px Arial';
ctx.fillText("Choose language", cW/2+i/9, cH/2-mWH*0.06+0.5*i);
}
for (var i=2;i<=41;i++){
var px,py,t=Math.sin((new Date - hitboxs[i][10])/5000)*0.15;
px=hitboxs[i][8]*Math.cos(t)-hitboxs[i][9]*Math.sin(t);
py=hitboxs[i][8]*Math.sin(t)+hitboxs[i][9]*Math.cos(t);
drawButton(ctx, cW/2+mWH*px, cH/2+mWH*py, mWH*0.05, mWH*0.05, hitboxs[i][4]/3, 2, i);
}
requestAnimationFrame(render);
}
var mousestatus=0;
var mouselastX=0,mouselastY=0;
function hitboxMove(ind,isPress)
{
if (ind==0 || ind==1){
if (isPress==0) hitboxs[ind][5]=0.9;
if (isPress==1) hitboxs[ind][5]=0.3;
if (isPress==2) {hitboxs[ind][5]=1; console.log(ind,isPress);}
hitboxs[ind][6] = new Date;
}else if (2<=ind || ind<=41){
if (isPress==0) hitboxs[ind][5]=0.9;
if (isPress==1) hitboxs[ind][5]=0.3;
if (isPress==2) {hitboxs[ind][5]=1;}
hitboxs[ind][6] = new Date;
}
// console.log(ind,isPress);
}
function mouseDown(e)
{
mousestatus = 1;
mouselastX = parseFloat(getPosition(e).split(':')[0]);
mouselastY = parseFloat(getPosition(e).split(':')[1]);
mouseMove(e);
}
function mouseMove(e)
{
var posX = parseFloat(getPosition(e).split(':')[0]);
var posY = parseFloat(getPosition(e).split(':')[1]);
hitboxs.forEach((e,i) =>{if (containPoint(e[0],e[1],e[2],e[3],posX,posY)) hitboxMove(i,mousestatus)});
mouselastX = posX;
mouselastY = posY;
}
function mouseUp(e)
{
mousestatus = 2;
mouseMove(e);
mousestatus = 0;
}
</script>
<style>
</style>
</head>
<body onload="onload();">
<canvas id="canvas" width="1920" height="1080" style="height:100%;width:100%;position: absolute;top: 0%;left: 0%;"></canvas>
</body>
</html>