-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
649 lines (612 loc) · 18.6 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
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
---
layout: default
title: "Home"
description: ""
---
<canvas id="canvas" class="canvas_full2 pixelated" width="256" height="64"></canvas>
<h2><img src="./img/icons/home-0.png" class="pixelated" width="25" style="margin-right:8px;transform:scale(1.25);background-color:var(--md-sys-color-pixel-bg)">Home</h2>
<div style="padding:36px;border-radius:12px;outline:1px solid var(--md-sys-color-outline-variant);">
<img draggable="false" src="./img/icons/skin-2.png" class="pixelated" width="36" style="display:block;margin-left:-2px;margin-bottom:-50px;">
<img draggable="false" src="./img/icons/skin-1.png" class="pixelated" width="32" style="float:left;border-radius:4px;margin:16px 16px 0 0;">
<p style="margin:0;">
<br>
Hello! I'm Nxrix, a developer and artist who loves to play around with random, colorful things. I create voxel models, pixel art, and mini-apps or tools, I mostly use JS, C, Lua and GLSL.
</p>
</div>
<br>
<div class="cart_set">
{% for project in site.projects %}
{% unless project.hidden %}
<a href="{{ project.url }}" class="cart">
<img class="pixelated" src="./img/carts/{{ project.image }}">
<div class="content">
<div class="title">{{ project.title }}</div>
<div class="description">{{ project.description }}</div>
</div>
</a>
{% endunless %}
{% endfor %}
</div>
<script src="./js/three.min.js"></script>
<script>
/**
* @copyright (c) 2025 Nxrix. All rights reserved.
*/
"use strict";
const palette = [
[0x1d,0x18,0x26],[0x8b,0x7f,0xb0],[0xc3,0xbe,0xe5],[0xff,0xe8,0xe9],
[0x65,0x26,0x4e],[0xa0,0x1a,0x3d],[0xde,0x1b,0x45],[0xf2,0x63,0x7b],
[0x8b,0x3f,0x39],[0xbb,0x45,0x31],[0xef,0x5d,0x0e],[0xff,0x95,0x00],
[0x00,0xa0,0x3d],[0x12,0xd5,0x00],[0xb4,0xd8,0x00],[0xff,0xc3,0x1f],
[0x00,0x6e,0x69],[0x00,0xae,0x85],[0x00,0xda,0xa7],[0x4f,0xd6,0xff],
[0x2b,0x27,0x54],[0x3c,0x51,0xaf],[0x18,0x88,0xde],[0x00,0xa9,0xe1],
[0x59,0x3c,0x97],[0x89,0x44,0xcf],[0xb4,0x4a,0xff],[0xe9,0x59,0xff],
[0xe7,0x87,0x6d],[0xff,0xba,0x8c],[0xff,0xef,0x5c],[0xff,0x9c,0xde]
];
const width = 128;
const height = 32;
const width2 = width/2;
const height2 = height/2;
const widthm1 = width-1;
const heightm1 = height-1;
const buffer = new Uint8Array(width*height);
const palette_mask = [];
let pattern = 0;
let pattern_color = 0;
let cameraX = 0;
let cameraY = 0;
let clipX0 = 0;
let clipY0 = 0;
let clipX1 = width;
let clipY1 = height;
const font_buffer = [0,0,0,0,0,1,0,0,1,0,1,0,1,0,1,0,0,1,0,0,1,0,1,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,0,1,1,0,0,1,1,1,0,1,1,1,0,1,0,1,0,1,1,1,0,1,1,1,0,1,1,1,0,1,1,1,0,1,1,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,1,1,1,0,0,1,0,0,1,0,1,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,1,0,0,0,0,1,0,0,0,0,1,0,1,0,1,0,1,1,0,0,0,1,1,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,1,1,1,0,1,1,1,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0,0,1,0,0,1,0,0,0,0,1,0,0,1,1,1,0,0,1,0,0,0,1,0,0,0,1,0,0,1,1,1,0,1,0,1,0,0,1,0,0,0,0,0,0,1,0,1,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1,0,1,0,1,0,1,1,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,1,0,1,1,0,0,0,0,1,0,0,1,1,0,0,0,0,0,1,1,1,0,0,0,0,0,1,0,1,0,1,1,1,0,0,1,1,0,1,1,0,0,1,1,1,0,1,0,0,0,1,1,1,0,1,0,1,0,1,1,1,0,1,1,1,0,1,0,1,0,1,1,1,0,1,0,1,0,1,0,1,0,1,1,0,0,1,0,0,0,0,0,1,0,1,0,1,0,1,1,1,0,0,1,0,0,1,1,1,0,0,1,0,0,1,1,1,0,1,0,1,0,0,1,0,0,1,1,1,0,0,1,1,0,0,1,0,0,1,1,0,0,1,0,0,0];
const bayer4x4 = [
[ 0, 8, 2, 10],
[12, 4, 14, 6],
[ 3, 11, 1, 9],
[15, 7, 13, 5]
];
const bayer8x8 = [
[ 0, 32, 8, 40, 2, 34, 10, 42],
[48, 16, 56, 24, 50, 18, 58, 26],
[12, 44, 4, 36, 14, 46, 6, 38],
[60, 28, 52, 20, 62, 30, 54, 22],
[ 3, 35, 11, 43, 1, 33, 9, 41],
[51, 19, 59, 27, 49, 17, 57, 25],
[15, 47, 7, 39, 13, 45, 5, 37],
[63, 31, 55, 23, 61, 29, 53, 21]
];
const px8_pset = (x,y,col) => {
x -= cameraX;
y -= cameraY;
if (x>=clipX0&&x<clipX1&&y>=clipY0&&y<clipY1) {
col = Math.round(col);
const ptrn = pattern>>((~x&3)+((~y&3)<<2))&1;
col = ptrn?pattern_color:col;
if ((col>0||!ptrn)&&!palette_mask[col]) {
buffer[x+y*width] = col&31;
}
}
};
const cls = (col) => {
pattern = 0;
pattern_color = 0;
palette_mask.fill(false);
buffer.fill(Math.round(col)&0xff);
};
const pset = (x,y,col) => {
x = Math.round(x);
y = Math.round(y);
px8_pset(x,y,col);
};
const pget = (x, y) => {
x = Math.round(x)&widthm1;
y = Math.round(y)&heightm1;
return buffer[x+(y*width)];
};
const fillp = (p,col) => {
pattern = Math.round(p)||0;
pattern_color = Math.round(col)||0;
};
const palt = (col,t) => {
if (col) {
palette_mask[Math.round(col)&0xff]=t;
} else {
palette_mask.fill(false);
}
};
const camera = (x, y) => {
cameraX = Math.round(x)||0;
cameraY = Math.round(y)||0;
};
const clip = (x0,y0,x1,y1) => {
clipX0 = Math.round(x0)||0;
clipY0 = Math.round(y0)||0;
clipX1 = Math.round(x1)||width;
clipY1 = Math.round(y1)||height;
};
const line = (x0,y0,x1,y1,col) => {
x0 = Math.round(x0);
y0 = Math.round(y0);
x1 = Math.round(x1);
y1 = Math.round(y1);
const dx = Math.abs(x1-x0);
const dy = Math.abs(y1-y0);
const sx = (x0<x1)?1:-1;
const sy = (y0<y1)?1:-1;
let err = dx-dy;
while (true) {
px8_pset(x0,y0,col);
if (x0==x1&&y0==y1) break;
const e2 = err*2;
if (e2>-dy) { err -= dy;x0 += sx; }
if (e2< dx) { err += dx;y0 += sy; }
}
};
const rect = (x0,y0,x1,y1,col) => {
x0 = Math.round(x0);
y0 = Math.round(y0);
x1 = Math.round(x1);
y1 = Math.round(y1);
if (x0>x1) {
const temp = x0;
x0 = x1;
x1 = temp;
}
if (y0>y1) {
const temp = y0;
y0 = y1;
y1 = temp;
}
for (let x=x0;x<=x1;x++) {
px8_pset(x,y0,col);
px8_pset(x,y1,col);
}
for (let y=y0;y<=y1;y++) {
px8_pset(x0,y,col);
px8_pset(x1,y,col);
}
};
const rectfill = (x0,y0,x1,y1,col) => {
x0 = Math.round(x0);
y0 = Math.round(y0);
x1 = Math.round(x1);
y1 = Math.round(y1);
if (x0 > x1) {
const temp = x0;
x0 = x1;
x1 = temp;
}
if (y0 > y1) {
const temp = y0;
y0 = y1;
y1 = temp;
}
for (let x=x0;x<=x1;x++) {
for (let y=y0;y<=y1;y++) {
px8_pset(x,y,col);
}
}
};
const circ = (x,y,r,col) => {
x = Math.round(x);
y = Math.round(y);
r = Math.round(r);
let f = 1-r;
let dx = 1;
let dy = -2*r;
let cx = 0;
let cy = r;
while (cx<=cy) {
px8_pset(x+cx,y+cy,col);
px8_pset(x-cx,y+cy,col);
px8_pset(x+cx,y-cy,col);
px8_pset(x-cx,y-cy,col);
px8_pset(x+cy,y+cx,col);
px8_pset(x-cy,y+cx,col);
px8_pset(x+cy,y-cx,col);
px8_pset(x-cy,y-cx,col);
if (f>=0) {
cy--;
dy += 2;
f += dy;
}
cx++;
dx += 2;
f += dx;
}
};
const circfill = (x, y, r, col) => {
x = Math.round(x);
y = Math.round(y);
r = Math.round(r);
let f = 1-r;
let dx = 1;
let dy = -2*r;
let cx = 0;
let cy = r;
const hline = (x1,x2,y) => {
for (let i=x1;i<=x2;i++) {
px8_pset(i,y,col);
}
};
while (cx<=cy) {
hline(x-cx,x+cx,y+cy);
hline(x-cx,x+cx,y-cy);
hline(x-cy,x+cy,y+cx);
hline(x-cy,x+cy,y-cx);
if (f >= 0) {
cy--;
dy += 2;
f += dy;
}
cx++;
dx += 2;
f += dx;
}
};
const tri = (x0,y0,x1,y1,x2,y2,col) => {
line(x0,y0,x1,y1,col);
line(x1,y1,x2,y2,col);
line(x2,y2,x0,y0,col);
};
const trifill = (x0,y0,x1,y1,x2,y2,col) => {
x0 = Math.round(x0);
y0 = Math.round(y0);
x1 = Math.round(x1);
y1 = Math.round(y1);
x2 = Math.round(x2);
y2 = Math.round(y2);
if (y0>y1) {
let temp = y0;
y0 = y1;
y1 = temp;
temp = x0;
x0 = x1;
x1 = temp;
}
if (y1>y2) {
let temp = y1;
y1 = y2;
y2 = temp;
temp = x1;
x1 = x2;
x2 = temp;
}
if (y0>y1) {
let temp = y0;
y0 = y1;
y1 = temp;
temp = x0;
x0 = x1;
x1 = temp;
}
const dx1 = x1-x0;
const dy1 = y1-y0;
const dx2 = x2-x0;
const dy2 = y2-y0;
const dx3 = x2-x1;
const dy3 = y2-y1;
const m1 = dx1/dy1;
const m2 = dx2/dy2;
const m3 = dx3/dy3;
let xl = x0;
let xr = x0;
for (let i=y0;i<=y1;i++) {
line(xl,i,xr,i,col);
xl += m1;
xr += m2;
}
xl = x1;
xr = x0;
for (let i=y1;i<=y2;i++) {
line(xl,i,xr,i,col);
xl += m3;
xr += m2;
}
};
const sspr = (spr,x,y,w,h) => {
x = Math.round(x);
y = Math.round(y);
spr = spr.split(",");
const w1 = spr[0];
const h1 = spr[1];
spr = spr[2].split("");
for (let i=0;i<w;i++) {
for (let j=0;j<h;j++) {
const col = parseInt(spr[Math.floor(i/w*w1)+Math.floor(j/h*h1)*w1],33);
if (col<32) {
px8_pset(x+i,y+j,col);
}
}
}
};
const print = (text,x,y,col) => {
x = Math.round(x);
y = Math.round(y);
text = text.toString();
const lines = text.split("\n");
for (let l=0;l<lines.length;l++) {
const line = lines[l];
const cy = y+l*5;
for (let i=0;i<line.length;i++) {
const code = line.charCodeAt(i);
const cx = x+i*4;
for (let j=0;j<5;j++) {
for (let k=0;k<4;k++) {
if (font_buffer[(code-32)*4+j*380+k]==1) {
px8_pset(cx+k,cy+j,col);
}
}
}
}
}
};
const context = canvas.getContext("webgl",{ antialias: false, preserveDrawingBuffer: true });
const renderer = new THREE.WebGLRenderer({canvas:canvas,context:context});
renderer.setPixelRatio(Math.min(window.devicePixelRatio,1));
renderer.outputColorSpace = THREE.LinearSRGBColorSpace;
const cam = new THREE.PerspectiveCamera(90,2,0.125,256);
const scene = new THREE.Scene();
cam.position.set(0,0,0);
cam.lookAt(0,0,1);
const buffer_texture = new THREE.DataTexture(buffer,width,height,THREE.AlphaFormat,THREE.UnsignedByteType);
const data_pal = new Uint8Array(32*4);
for (let i=0;i<32;i++) {
const c = palette[i&31];
const n = i*4;
data_pal[n ] = c[0];
data_pal[n+1] = c[1];
data_pal[n+2] = c[2];
data_pal[n+3] = 255;
}
const palette_texture = new THREE.DataTexture(data_pal,32,1,THREE.RGBAFormat,THREE.UnsignedByteType);
palette_texture.needsUpdate = true;
const plane = new THREE.Mesh(new THREE.PlaneGeometry(30, 15),new THREE.ShaderMaterial({
uniforms: {
uPalette: { value: palette_texture },
uBuffer: { value: buffer_texture },
},
vertexShader: `
varying vec2 vU;
void main() {
vU = uv;
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
}`,
fragmentShader: `
uniform sampler2D uPalette;
uniform sampler2D uBuffer;
varying vec2 vU;
void main() {
vec3 c = texture2D(uPalette,vec2(texture2D(uBuffer,vU*vec2(1,-1)+vec2(0,1)).a*8.0,0)).rgb;
gl_FragColor = vec4(c,1.0);
}`,
}));
plane.rotation.y = -Math.PI;
plane.position.z = 7.5;
scene.add(plane);
/*class srnd {
static d = 0xFFFFFFFF;
static u = 1664525;
static a = 1013904223;
gen(s) {
return ((s*srnd.u+srnd.a)%srnd.d)/srnd.d;
}
}*/
/*class srnd {
lcg(seed) {
const a = 1664525;
const c = 1013904223;
const m = Math.pow(2,32);
return (seed*a+c)%m;
}
gen(n) {
return this.lcg(n)%33;
}
}*/
/*class srnd {
gen(n) {
let hash = 0;
for (let i = 0; i < n.toString().length; i++) {
hash = (hash << 5) - hash + n.toString().charCodeAt(i);
hash |= 0;
}
return Math.abs(hash)&0xffff;
}
}*/
class srnd {
gen(n) {
const a = 1664525;
const c = 1013904223;
n = n|0;
n = (a*n+c)&0xFFFFFFFF;
return (n>>>16)&0xFFFF;
}
}
class frnd {
fh(n,f=2) {
return (n^(n%2)^(n%3)^(n%5)^(n%7)^(n%11)^(n%13)^(n%17)^(n%19)^(n%27)^(n%29))%f/(f-1);
}
gen(n) {
return this.fh(n,32);
}
}
let events = {
1: [
{
day: 10,
solar: true,
offset: 3,
icon: "5,6,wwfwwfffffbfffb2fbf2wb2bww2w2w",
w: 5,
c1: 25,
c2: 26,
},
{
day: 24,
solar: true,
offset: 3,
icon: "5,6,wwfwwfffffbfffb2fbf2wb2bww2w2w",
w: 5,
c1: 0,
c2: 20,
}
],
2: [
{
day: 14,
solar: false,
icon: "5,6,55w55565654565424542w242www2ww",
w: 5,
c1: 5,
c2: 6,
}
],
12: [
{
day: 25,
solar: false,
icon: "5,6,wwfwwwgg6ww6ccwggggg22822ww2ww",
w: 5,
c1: [5,16,2],
c2: [6,17,3],
}
]
};
const leap_year = (year) => {
//return (year%4==0&&year%100!=0)||(year%400==0);
return (year%4==0);
}
const find_event = (input) => {
const date = (input instanceof Date)?input:new Date(input);
const year = date.getFullYear();
const month = date.getMonth()+1;
const day = date.getDate();
const e = events[month]||[];
for (const event of e) {
let eday = event.day;
if (event.solar&&leap_year(year+event.offset)) eday-=1;
if (day==eday) {
return event;
}
}
return null;
}
//---1632640020000---//
const k = new Date("2021-09-26T10:37:00.000+03:30");
const _second = 1000;
const _minute = _second*60;
const _hour = _minute*60;
const _day = _hour*24;
const _month = _day*30;
const _year = _month*12;
let t = 0;
let update = () => {
cls();
const date = new Date();
const now = new Date(date.getTime());
const e = find_event(now);
const dist = now-k;
const d = Math.floor(dist/_day);
const h = Math.floor((dist% _day)/ _hour).toString().padStart(2,0);
const m = Math.floor((dist% _hour)/ _minute).toString().padStart(2,0);
const s = Math.floor((dist%_minute)/_second).toString().padStart(2,0);
const str1 = `${d}`;
const str2 = `${h}:${m}:${s}`;
const w = e!==null?e.w:0;
const strl2 = str1.length+w/4+1/2+str2.length;
const str2p = w+str1.length*4+3;
const rnd = new srnd();
const n = Math.floor(dist/1000);
const rn = rnd.gen(n);
let c1 = rn&31;
let c2 = rn+1;
if (rn&3==3) {
c2 = rn-1;
}
if (c1==0) c2 = 20;
if (c1==1) c2 = 20;
if (c1==14) c2 = 13;
if (c1==14) c1 = 12;
if (c1==15) c2 = 11;
if (c1==18) c2 = 23;
if (c1==19) c2 = 23;
if (c1==30) c2 = 11;
if (c1==30) c1 = 10;
if (c1==31) c2 = 27;
if (e!=null) {
if (Array.isArray(e.c1)) {
c1 = e.c1[rn%e.c1.length];
} else {
c1 = e.c1;
}
if (Array.isArray(e.c2)) {
c2 = e.c2[rn%e.c2.length];
} else {
c2 = e.c2;
}
}
fillp(rn,c2);
for (let i=0;i<width;i++) {
for (let j=0;j<height;j++) {
pset(i,j,c1);
}
}
fillp();
for (let i=0;i<4*strl2+8;i++) {
for (let j=0;j<12;j++) {
let v = 3;
if ((i==1||j==1||i==strl2*4+6||j==10)&&(i>0)&&(j>0)&&(i<strl2*4+7)&&(j<11)) {
v = (Math.abs(i-(4*strl2+6)/2)^Math.abs(j-5.5))+n*4+t/4;
}
pset(i+width2-4-strl2*2,j+height2-6,v);
}
}
if (e!=null) {
sspr(e.icon,17+width2-2*strl2,height2-3,e.w,6);
}
//print(str,width2-1-2*strl,height2-3,20);
//print(str,width2 -2*strl,height2-3,20);
//print(str,width2+1-2*strl,height2-3,20);
//print(str,width2-1-2*strl,height2-2,0);
//print(str,width2+1-2*strl,height2-2,0);
//print(str,width2-1-2*strl,height2-1,0);
//print(str,width2 -2*strl,height2-1,0);
//print(str,width2+1-2*strl,height2-1,0);
print(str1,width2-2*strl2-1,height2-3,20);
print(str1,width2-2*strl2 ,height2-3,20);
print(str1,width2-2*strl2+1,height2-3,20);
print(str1,width2-2*strl2-1,height2-2,0);
print(str1,width2-2*strl2+1,height2-2,0);
print(str1,width2-2*strl2-1,height2-1,0);
print(str1,width2-2*strl2 ,height2-1,0);
print(str1,width2-2*strl2+1,height2-1,0);
print(str2,str2p+width2-2*strl2-1,height2-3,20);
print(str2,str2p+width2-2*strl2 ,height2-3,20);
print(str2,str2p+width2-2*strl2+1,height2-3,20);
print(str2,str2p+width2-2*strl2-1,height2-2,0);
print(str2,str2p+width2-2*strl2+1,height2-2,0);
print(str2,str2p+width2-2*strl2-1,height2-1,0);
print(str2,str2p+width2-2*strl2 ,height2-1,0);
print(str2,str2p+width2-2*strl2+1,height2-1,0);
//print(str,width2-2*strl,height2-2,3);
print(str1,width2-2*strl2,height2-2,3);
print(str2,str2p+width2-2*strl2,height2-2,3);
/*const oldb = buffer;
const pget2 = (x,y) => {
x = x&widthm1;
y = y&heightm1;
return oldb[x+y*width];
}
for (let i=0;i<width;i++) {
for (let j=0;j<height;j++) {
pset(i,j,pget2(i+rnd.gen(n*width+j+t),j));
}
}*/
buffer_texture.needsUpdate = true;
renderer.render(scene,cam);
t++;
requestAnimationFrame(update);
}
update();
</script>