-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
336 lines (300 loc) · 11.3 KB
/
index.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
335
336
<head>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link rel="stylesheet" href="style.css">
<link href="https://fonts.googleapis.com/css2?family=Montserrat:wght@300;400;500;700&family=Nabla&display=swap"
rel="stylesheet">
<link rel="icon" href="rukk.ico" type="image/x-icon">
<style>
.overlay {
backdrop-filter: blur(6px);
}
</style>
</head>
<body style="background-color: black">
<canvas id="canvas" style="position: absolute; z-index:-1;"></canvas>
<div class="overlay"
style="border-radius: 15px; padding: 50px 0px; position: absolute;left:50%; top: 50%;transform: translate(-50%, -50%); height:auto; width: 500px;background-color: rgba(0, 0, 0, 0.628);display: flex;justify-content: center;text-align: center; flex-direction: column;gap:0px;">
<!--<img src="rukkia.png" style="display: block; max-width: 1200px; margin: auto;">
-->
<p style="color: #a24ba4; font-size: 54px; font-family: 'Nabla', sans-serif;margin: 0px;">
Z E I N E B
</p>
<p style="margin: 0px 0px 50px 0px; font-size: 20px;color:rgb(255, 203, 30);">
nsit nawaratek 🙄...
</p>
<p id="counterValue"
style="margin: 0px;text-align: center; color: white; font-size: 34px; font-family: 'Montserrat', sans-serif;">
</p>
<button id="butt" onclick="IbUT()"
style="cursor:pointer; border-color: black; background-color: #a24ba4;height: 30px; width: 300px;margin-top: 30px;font-size: 20px; margin-left: auto; margin-right: auto; display: block; color: white;">
Hez nawara.</button>
<script>
console.log("RUKK<3");
const jsonBinUrl = 'https://api.jsonbin.io/v3/b/6535d8ec0574da7622bc62fb';
let counter = -1;
let req = new XMLHttpRequest();
document.getElementById('butt').style.display = 'none';
//document.getElementById('counterValue').style.display = 'none';
const alreadyResponded = document.cookie.split(';').find(cookie => cookie.trim().startsWith('alreadyResponded=true'));
console.log("previously responded = ", alreadyResponded);
req.onreadystatechange = () => {
if (req.readyState == XMLHttpRequest.DONE) {
let json = JSON.parse(req.responseText);
counter = json.value;
print();
//if (!alreadyResponded)
document.getElementById('butt').style.display = 'block';
}
};
req.open("GET", jsonBinUrl + "/latest?meta=false", true);
req.setRequestHeader("X-Master-Key", "$2a$10$Nf/VWZdJnACZC1yMxdv8DOdpR/rnllHVbLS0kxclu6W3cphswi/N.");
req.send();
function IbUT() {
if (counter == -1) return;
let req = new XMLHttpRequest();
req.onreadystatechange = () => {
if (req.readyState == XMLHttpRequest.DONE) {
if (req.status != 200)
return;
let json = JSON.parse(req.responseText);
counter = json.record.value;
print();
document.cookie = 'alreadyResponded=true'; // Expires in one year
//document.getElementById('counterValue').style.display = '';
}
};
req.open("PUT", jsonBinUrl, true);
req.setRequestHeader("Content-Type", "application/json");
req.setRequestHeader("X-Master-Key", '$2a$10$Nf/VWZdJnACZC1yMxdv8DOdpR/rnllHVbLS0kxclu6W3cphswi/N.');
req.setRequestHeader("X-Bin-Versioning", false);
counter++;
const data = {
value: counter // or use your counter variable here
};
req.send(JSON.stringify(data));
document.getElementById('butt').style.display = 'none';
}
function print() /////////////////////////////////////////////<<<<<<<<<<<<<
{
const val = `${counter} nawara tnatchet 😳`;
document.getElementById('counterValue').textContent = val;
}
</script>
<script>
//fields
var canvas = document.getElementById("canvas");
var body = document.getElementsByTagName("body")[0];
var positions = []
var ctx = canvas.getContext("2d");
const MINPETAL = 5
const MAXPETAL = 13
var pistilC, petalC, pistilC2, petalC2
/*Initialize flowers*/
body.addEventListener("click", function (ev) {
drawFlowers()
})
window.onload = drawFlowers
window.onresize = drawFlowers
/*Flower flunctions*/
function drawFlowers() {
scaleCanvas()
//background color
ctx.clearRect(0, 0, canvas.width, canvas.height)
positions = []
body.style.filter = chance(.12) ? `grayscale(${getRandomInt(0, 80)}%)` : ""
let mode = pick(["daisies", "multi", "quad", "roses", "crosshatch", "blueYellow", "greenRed"])
let bg = new randomColor(minSat = 50)
if (mode == "daisies") bg.l = getRandomInt(0, 50)
canvas.style.backgroundColor = bg.hsl()
//themes hsl=pistil color hsl2=petal color
var colorz = {
"daisies": { h2: 12, s2: 38, l2: 97, h: 45, s: 92, l: 52, vary: 20, mix: false },
"roses": { h: 1, s: 91, l: 46, h2: 1, s2: 91, l2: 30, vary: 20, mix: true },
"crosshatch": { h: 1, s: 91, l: 46, vary: 80, mix: true },/*only defines one varying pistil color*/
"greenRed": { h: 102, s: 72, l: 27, h2: 348, s2: 89, l2: 42, vary: 20, mix: false },
"blueYellow": { h: 45, s: 99, l: 50, h2: 240, s2: 67, l2: 58, vary: 10, mix: false },
}
//drawing options
var opt = {
mode: mode,
spaceAround: chance(),
allowLarge: chance(),
padding: getRandomInt(1, 4),
innerDetails: chance(),
petalIterations: 4,
minOpacity: getRandomFloat(.5, .9),
invertColors: chance(.25)
}
//assign colors
let colorOpt = colorz[mode]
let colors = getThemeColors(colorOpt) /*pistil color at index 0, petal color at index 1*/
if (opt.invertColors) {
petalC = colors[0].hsl()
pistilC = colors[1].hsl()
} else {
petalC = colors[1].hsl()
pistilC = colors[0].hsl()
}
colors = getThemeColors(colorOpt)
if (opt.invertColors) {
petalC2 = colors[0].hsl()
pistilC2 = colors[1].hsl()
} else {
if (colorOpt && colorOpt.mix) {/*switching petals and pistil color*/
petalC2 = colors[0].hsl()
pistilC2 = colors[1].hsl()
} else {
petalC2 = colors[1].hsl()
pistilC2 = colors[0].hsl()
}
}
//draw the flowers
let numFlower = mode == "multi" ? getRandomInt(50, 1000) : getRandomInt(40, 250)
for (let i = 0; i < numFlower; i++) {
if (mode == "multi") {
pistilC = new randomColor(minSat = 50).hsl()
petalC = new randomColor(minSat = 50).hsl()
pistilC2 = new randomColor(minSat = 50).hsl()
petalC2 = new randomColor(minSat = 50).hsl()
}
drawFlower(opt)
}
}
function drawFlower(opt) {
let f = new Flower(opt);
if (!f) return false;
positions.push(new Point(f.x, f.y))
ctx.save();
ctx.globalAlpha = f.opacity
ctx.lineWidth = f.lw;
ctx.translate(f.x, f.y);
ctx.rotate(f.rad);
ctx.translate(-f.x, -f.y);
ctx.fillStyle = chance() ? petalC2 : petalC
ctx.strokeStyle = ctx.fillStyle
//petals
for (let i = 0; i < f.petals; i++) {
ctx.translate(f.x, f.y);
ctx.rotate((f.rotate * Math.PI) / 180);
ctx.translate(-f.x, -f.y);
ctx.beginPath();
ctx.moveTo(f.x, f.y - f.shiftOut);
for (let j = 0; j < opt.petalIterations; j++) {
let sp1 = f.r * f.petalSpread1
let len1 = f.r * f.petalLength1
let sp2 = f.r * f.petalSpread2
let len2 = f.r * f.petalLength2
let endX = f.petalBase
let endY = f.shiftOut
ctx.translate(f.x, f.y);
if (j % 2 == 0) {/*symmetric rotations for more symmetric petals, rando for some irregularity*/
ctx.rotate((j * (360 / opt.petalIterations) * Math.PI) / 180);
} else {
ctx.rotate((j * (getRandomInt(1, 4)) * Math.PI) / 180);
}
ctx.translate(-f.x, -f.y);
ctx.bezierCurveTo(f.x - sp1,/*control point #1 'upper left'*/
f.y - len1,
f.x + sp2,/*control point #2 'upper right'*/
f.y - len2,
f.x + endX,/*ending point*/
f.y - endY)
if (opt.innerDetails) ctx.quadraticCurveTo(
f.x,/*control point*/
f.y + f.r,
f.x + getRandomInt(0, 5),/*ending point*/
f.y)
}
ctx.fill();
ctx.closePath();
ctx.beginPath()
}
//pistil
for (let j = 0; j < 3; j++) {
ctx.arc(f.x + getRandomFloat(-2, 2), f.y + getRandomFloat(-2, 2), (f.r / f.centerDivisor), 0, 360)
}
ctx.strokeStyle = petalC;
ctx.fillStyle = opt.mode != "crosshatch" && opt.mode != "daisies" ? (chance() ? pistilC2 : pistilC) : pistilC;
ctx.globalAlpha = 1;
ctx.fill();
ctx.restore();
}
function Flower(opt) {
this.r = opt.allowLarge && chance(.05) ? getRandomInt(50, 150) : getRandomInt(20, 50)
this.x = getRandomInt(0, canvas.width)
this.y = getRandomInt(0, canvas.height)
if (opt.spaceAround && positions.some(pos => {
let d = distance(new Point(this.x, this.y), new Point(pos.x, pos.y))
return d < this.r * opt.padding
})) {
return false;
}
this.lw = 4;
this.angle = getRandomInt(0, 360)
this.rad = (this.angle * Math.PI) / 180
this.opacity = getRandomFloat(opt.minOpacity, 1)
this.petals = this.r <= 40 ? getRandomInt(3, 9) : getRandomInt(MINPETAL, MAXPETAL)
this.shiftOut = getRandomFloat(0, this.r / 3)
this.petalBase = getRandomInt(0, 5);//getRandomInt(0,this.r<25?5:10)
this.centerDivisor = getRandomFloat(3, 9)
this.petalSpread1 = getRandomFloat(.3, this.petals <= 7 ? .7 : .5)
this.petalLength1 = getRandomFloat(.9, 2)
this.petalSpread2 = getRandomFloat(this.petalSpread1 - .2, this.petalSpread1 + .2);
this.petalLength2 = getRandomFloat(.9, 2)
this.rotate = Math.floor(360 / this.petals);
}
function getThemeColors(opt) {
let dPetal = new randomColor()
let dPistil = new randomColor()
if (!opt) return [dPistil, dPetal]
if (opt.h) dPetal.h = opt.h + getRandomInt(-opt.vary, opt.vary)
if (opt.s) dPetal.s = opt.s + getRandomInt(-opt.vary, opt.vary)
if (opt.l) dPetal.l = opt.l + getRandomInt(-opt.vary, opt.vary)
if (opt.h2) dPistil.h = opt.h2 + getRandomInt(-opt.vary, opt.vary)
if (opt.s2) dPistil.s = opt.s2 + getRandomInt(-opt.vary, opt.vary)
if (opt.l2) dPistil.l = opt.l2 + getRandomInt(-opt.vary, opt.vary)
return [dPetal, dPistil]
}
/*utility*/
function scaleCanvas() {
var w = Math.max(document.documentElement.clientWidth, window.innerWidth);
var h = Math.max(document.documentElement.clientHeight, window.innerHeight);
console.log(`width:${w},height:${h}`)
canvas.style.width = w + "px";
canvas.style.height = h + "px";
var scale = 1;//window.devicePixelRatio;
canvas.width = Math.floor(w * scale);
canvas.height = Math.floor(h * scale);
ctx.scale(scale, scale);
}
function distance(p1, p2) {
return Math.floor(Math.sqrt(Math.pow(p1.x - p2.x, 2) + Math.pow(p1.y - p2.y, 2)))
}
function randomColor(minSat = 0, maxSat = 100, minBright = 0, maxBright = 100) {
this.h = 281
this.s = 85
this.l = getRandomInt(24, 75)
this.hsl = () => { return `hsl(${this.h},${this.s}%,${this.l}%)` };
}
function getRandomInt(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min + 1)) + min;
}
function getRandomFloat(min, max) {
return Math.random() * (max - min) + min;
}
function pick(arr) {
return arr[Math.floor(Math.random() * arr.length)];
}
function chance(limit = 0.5) {
return Math.random() < limit;
}
function Point(x, y) {
this.x = x
this.y = y
}
</script>
</div>
</body>