-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPosterLoomPage.jsx
More file actions
628 lines (580 loc) · 23.9 KB
/
PosterLoomPage.jsx
File metadata and controls
628 lines (580 loc) · 23.9 KB
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
import React, { useState, useRef, useEffect, useCallback } from 'react';
import { Link } from 'react-router-dom';
import {
ArrowLeft,
Trash,
ArrowsClockwise,
TextAa,
Selection,
Info,
DownloadSimple,
PaintBrush,
} from '@phosphor-icons/react';
import Seo from '../../components/Seo';
import { useToast } from '../../hooks/useToast';
const LAYOUTS = [
{ id: 'bauhaus', label: 'BAUHAUS_GRID' },
{ id: 'technical', label: 'TECH_SPEC' },
{ id: 'minimal', label: 'THE_VOID' },
{ id: 'column', label: 'THE_COLUMN' },
{ id: 'diagonal', label: 'DIAGONAL_SCAN' },
];
const COLORS = [
{ name: 'Pure Void', hex: '#050505', text: '#FFFFFF' },
{ name: 'Emerald Flux', hex: '#10b981', text: '#000000' },
{ name: 'Salmon Signal', hex: '#FA8072', text: '#000000' },
{ name: 'Cyber Cyan', hex: '#00FFFF', text: '#000000' },
{ name: 'Neon Violet', hex: '#a855f7', text: '#000000' },
{ name: 'Amber Warning', hex: '#f59e0b', text: '#000000' },
{ name: 'White Light', hex: '#FFFFFF', text: '#000000' },
];
const PosterLoomPage = () => {
const appName = 'Poster Loom';
const { addToast } = useToast();
const canvasRef = useRef(null);
// Poster State
const [layout, setLayout] = useState('bauhaus');
const [primaryColor, setPrimaryColor] = useState(COLORS[0]);
const [accentColor, setAccentColor] = useState(COLORS[1]);
const [headerText, setHeaderText] = useState('FEZCODEX');
const [subHeaderText, setSubHeaderText] = useState('ARCHITECTURAL_THOUGHTS');
const [sidebarText, setSidebarText] = useState('DATA_NODE_049');
const [footerText, setFooterText] = useState(
'SYSTEM_INTEGRITY_VERIFIED // BUILD_2025',
);
const [headerSize, setHeaderSize] = useState(120);
const [subHeaderSize, setSubHeaderSize] = useState(24);
const [sidebarSize, setSidebarSize] = useState(18);
const [footerSize, setFooterSize] = useState(14);
const [noiseOpacity, setNoiseOpacity] = useState(0.1);
const [gridOpacity, setGridOpacity] = useState(0.2);
const [seed, setSeed] = useState(Math.random());
const drawPoster = useCallback(
(ctx, width, height) => {
const scale = width / 1000;
const padding = 60 * scale;
// 1. Background
ctx.fillStyle = primaryColor.hex;
ctx.fillRect(0, 0, width, height);
// 2. Grid Layer
if (gridOpacity > 0) {
ctx.strokeStyle = accentColor.hex;
ctx.globalAlpha = gridOpacity;
ctx.lineWidth = 1 * scale;
const gridSize = 50 * scale;
ctx.beginPath();
for (let x = 0; x <= width; x += gridSize) {
ctx.moveTo(x, 0);
ctx.lineTo(x, height);
}
for (let y = 0; y <= height; y += gridSize) {
ctx.moveTo(0, y);
ctx.lineTo(width, y);
}
ctx.stroke();
ctx.globalAlpha = 1.0;
}
// 3. Generative Shapes (based on seed)
const rng = (s) => {
let v = s * 12345.678;
return () => {
v = (v * 987.654) % 1;
return v;
};
};
const getRand = rng(seed);
ctx.save();
ctx.strokeStyle = accentColor.hex;
ctx.lineWidth = 2 * scale;
// Draw layout-specific shapes
if (layout === 'bauhaus') {
for (let i = 0; i < 5; i++) {
ctx.strokeRect(
getRand() * width,
getRand() * height,
200 * scale * getRand(),
200 * scale * getRand(),
);
ctx.beginPath();
ctx.arc(
getRand() * width,
getRand() * height,
100 * scale * getRand(),
0,
Math.PI * 2,
);
ctx.stroke();
}
} else if (layout === 'technical') {
ctx.beginPath();
ctx.moveTo(width / 2, padding);
ctx.lineTo(width / 2, height - padding);
ctx.stroke();
for (let i = 0; i < 10; i++) {
const y = padding + getRand() * (height - padding * 2);
ctx.strokeRect(width / 2 - 20 * scale, y, 40 * scale, 2 * scale);
}
} else if (layout === 'minimal') {
// The Void: Central Crosshair
const cx = width / 2;
const cy = height / 2;
const size = 100 * scale;
ctx.beginPath();
ctx.moveTo(cx - size, cy);
ctx.lineTo(cx + size, cy);
ctx.moveTo(cx, cy - size);
ctx.lineTo(cx, cy + size);
ctx.stroke();
ctx.strokeRect(cx - size / 4, cy - size / 4, size / 2, size / 2);
} else if (layout === 'column') {
// The Column: Vertical Structural Element
const colX = padding * 3;
ctx.beginPath();
ctx.moveTo(colX, padding);
ctx.lineTo(colX, height - padding);
ctx.stroke();
for (let i = 0; i < 20; i++) {
const y = padding + (i * (height - padding * 2)) / 20;
ctx.strokeRect(colX - 10 * scale, y, 20 * scale, 1 * scale);
}
} else if (layout === 'diagonal') {
// Diagonal Scan: 45-degree rotated lines
ctx.save();
ctx.globalAlpha = gridOpacity;
ctx.lineWidth = 2 * scale;
const step = 40 * scale;
for (let i = -height; i < width + height; i += step) {
ctx.beginPath();
ctx.moveTo(i, 0);
ctx.lineTo(i + height, height);
ctx.stroke();
}
ctx.restore();
}
ctx.restore();
// 4. Typography
ctx.fillStyle = accentColor.hex;
ctx.textBaseline = 'top';
// Header
ctx.font = `bold ${headerSize * scale}px "JetBrains Mono", monospace`;
ctx.textAlign = 'left';
ctx.fillText(headerText.toUpperCase(), padding, padding);
// Subheader
ctx.font = `bold ${subHeaderSize * scale}px "JetBrains Mono", monospace`;
ctx.fillText(
subHeaderText.toUpperCase(),
padding,
padding + (headerSize + 20) * scale,
);
// Sidebar (Vertical)
ctx.save();
ctx.translate(width - padding, height / 2);
ctx.rotate(Math.PI / 2);
ctx.textAlign = 'center';
ctx.font = `bold ${sidebarSize * scale}px "JetBrains Mono", monospace`;
ctx.fillText(sidebarText.toUpperCase(), 0, 0);
ctx.restore();
// Footer
ctx.font = `bold ${footerSize * scale}px "JetBrains Mono", monospace`;
ctx.textAlign = 'left';
ctx.fillText(
footerText.toUpperCase(),
padding,
height - padding - footerSize * scale,
);
// 5. Border
ctx.strokeStyle = accentColor.hex;
ctx.lineWidth = 10 * scale;
ctx.strokeRect(
padding / 2,
padding / 2,
width - padding,
height - padding,
);
// 6. Noise Layer
if (noiseOpacity > 0) {
const noiseSize = 256;
const noiseCanvas = document.createElement('canvas');
noiseCanvas.width = noiseSize;
noiseCanvas.height = noiseSize;
const nCtx = noiseCanvas.getContext('2d');
const nData = nCtx.createImageData(noiseSize, noiseSize);
for (let i = 0; i < nData.data.length; i += 4) {
const val = Math.random() * 255;
nData.data[i] = nData.data[i + 1] = nData.data[i + 2] = val;
nData.data[i + 3] = 255;
}
nCtx.putImageData(nData, 0, 0);
ctx.save();
ctx.globalAlpha = noiseOpacity;
ctx.globalCompositeOperation = 'overlay';
const pattern = ctx.createPattern(noiseCanvas, 'repeat');
ctx.fillStyle = pattern;
ctx.fillRect(0, 0, width, height);
ctx.restore();
}
},
[
layout,
primaryColor,
accentColor,
headerText,
subHeaderText,
sidebarText,
footerText,
headerSize,
subHeaderSize,
sidebarSize,
footerSize,
noiseOpacity,
gridOpacity,
seed,
],
);
useEffect(() => {
const canvas = canvasRef.current;
if (!canvas) return;
const ctx = canvas.getContext('2d');
const dpr = window.devicePixelRatio || 1;
const rect = canvas.getBoundingClientRect();
canvas.width = rect.width * dpr;
canvas.height = rect.height * dpr;
ctx.scale(dpr, dpr);
drawPoster(ctx, rect.width, rect.height);
}, [drawPoster]);
const handleDownload = () => {
const canvas = document.createElement('canvas');
const ctx = canvas.getContext('2d');
const W = 2160; // 4K vertical-ish scale
const H = 3240;
canvas.width = W;
canvas.height = H;
drawPoster(ctx, W, H);
const link = document.createElement('a');
link.download = `poster-loom-${Date.now()}.png`;
link.href = canvas.toDataURL('image/png', 1.0);
link.click();
addToast({
title: 'EXPORT_SUCCESS',
message: 'High-fidelity poster sequence generated.',
});
};
return (
<div className="min-h-screen bg-[#050505] text-white selection:bg-emerald-500/30 font-sans">
<Seo
title="Poster Loom | Fezcodex"
description="Construct high-impact brutalist posters with generative shapes and technical typography."
keywords={[
'Fezcodex',
'poster generator',
'brutalist design',
'generative art',
'typography tool',
]}
/>
<div className="mx-auto max-w-7xl px-6 py-24 md:px-12">
<header className="mb-24">
<Link
to="/apps"
className="group mb-12 inline-flex items-center gap-2 text-xs font-mono text-gray-500 hover:text-white transition-colors uppercase tracking-[0.3em]"
>
<ArrowLeft weight="bold" />
<span>Applications</span>
</Link>
<div className="flex flex-col md:flex-row md:items-end justify-between gap-12">
<div className="space-y-4">
<h1 className="text-6xl md:text-8xl font-black tracking-tighter text-white leading-none uppercase">
{appName}
</h1>
<p className="text-xl text-gray-400 max-w-2xl font-light leading-relaxed">
Poster construct protocol. Map character strings and geometric
entities onto a structured grid to generate high-impact visual
sequences.
</p>
</div>
<button
onClick={handleDownload}
className="group relative inline-flex items-center gap-4 px-10 py-6 bg-white text-black hover:bg-emerald-400 transition-all duration-300 font-mono uppercase tracking-widest text-sm font-black rounded-sm shrink-0"
>
<DownloadSimple weight="bold" size={24} />
<span>Generate Master</span>
</button>
</div>
</header>
<div className="grid grid-cols-1 lg:grid-cols-12 gap-12">
{/* LEFT: Controls */}
<div className="lg:col-span-4 space-y-8">
{/* Layout & Colors */}
<div className="border border-white/10 bg-white/[0.02] p-8 rounded-sm space-y-10">
<div className="flex justify-between items-center border-b border-white/5 pb-6">
<h3 className="font-mono text-[10px] font-bold text-emerald-500 uppercase tracking-widest flex items-center gap-2">
<Selection weight="fill" />
Structure_Protocols
</h3>
<button
onClick={() => setSeed(Math.random())}
className="p-1.5 text-gray-500 hover:text-emerald-500 transition-colors"
title="Regenerate Layout Entities"
>
<ArrowsClockwise weight="bold" size={14} />
</button>
</div>
<div className="space-y-6">
<div className="grid grid-cols-2 gap-2">
{LAYOUTS.map((l) => (
<button
key={l.id}
onClick={() => setLayout(l.id)}
className={`py-3 text-[9px] font-mono uppercase tracking-widest border transition-all ${layout === l.id ? 'bg-white text-black border-white' : 'border-white/5 text-gray-600 hover:border-white/20'}`}
>
{l.label}
</button>
))}
</div>
<div className="space-y-4">
<label className="block font-mono text-[9px] uppercase text-gray-600">
Base_Chromatic
</label>
<div className="flex gap-2">
{COLORS.map((c) => (
<button
key={c.name}
onClick={() => setPrimaryColor(c)}
className={`w-8 h-8 rounded-full border-2 ${primaryColor.hex === c.hex ? 'border-emerald-500 scale-110' : 'border-transparent'}`}
style={{ backgroundColor: c.hex }}
title={c.name}
/>
))}
</div>
</div>
<div className="space-y-4">
<label className="block font-mono text-[9px] uppercase text-gray-600">
Accent_Chromatic
</label>
<div className="flex gap-2">
{COLORS.map((c) => (
<button
key={c.name}
onClick={() => setAccentColor(c)}
className={`w-8 h-8 rounded-full border-2 ${accentColor.hex === c.hex ? 'border-emerald-500 scale-110' : 'border-transparent'}`}
style={{ backgroundColor: c.hex }}
title={c.name}
/>
))}
</div>
</div>
</div>
</div>
{/* Typography Inputs */}
<div className="border border-white/10 bg-white/[0.02] p-8 rounded-sm space-y-10">
<h3 className="font-mono text-[10px] font-bold text-emerald-500 uppercase tracking-widest flex items-center gap-2 border-b border-white/5 pb-6">
<TextAa weight="fill" />
String_Mapping
</h3>
<div className="space-y-10">
{/* Header Config */}
<div className="space-y-4">
<div className="flex justify-between items-center">
<label className="block font-mono text-[9px] uppercase text-gray-600">
Primary_Header
</label>
<div className="flex items-center gap-3">
<span className="text-[9px] font-mono text-gray-700">
{headerSize}PX
</span>
<input
type="range"
min="20"
max="250"
value={headerSize}
onChange={(e) =>
setHeaderSize(parseInt(e.target.value))
}
className="w-20 accent-white h-1 bg-gray-800 rounded-lg appearance-none cursor-pointer"
/>
</div>
</div>
<input
type="text"
value={headerText}
onChange={(e) => setHeaderText(e.target.value)}
className="w-full bg-black/40 border border-white/10 p-3 font-mono text-xs uppercase tracking-widest focus:border-emerald-500 outline-none transition-all"
/>
</div>
{/* SubHeader Config */}
<div className="space-y-4">
<div className="flex justify-between items-center">
<label className="block font-mono text-[9px] uppercase text-gray-600">
Secondary_Header
</label>
<div className="flex items-center gap-3">
<span className="text-[9px] font-mono text-gray-700">
{subHeaderSize}PX
</span>
<input
type="range"
min="8"
max="80"
value={subHeaderSize}
onChange={(e) =>
setSubHeaderSize(parseInt(e.target.value))
}
className="w-20 accent-white h-1 bg-gray-800 rounded-lg appearance-none cursor-pointer"
/>
</div>
</div>
<input
type="text"
value={subHeaderText}
onChange={(e) => setSubHeaderText(e.target.value)}
className="w-full bg-black/40 border border-white/10 p-3 font-mono text-xs uppercase tracking-widest focus:border-emerald-500 outline-none transition-all"
/>
</div>
{/* Sidebar Config */}
<div className="space-y-4">
<div className="flex justify-between items-center">
<label className="block font-mono text-[9px] uppercase text-gray-600">
Lateral_Registry
</label>
<div className="flex items-center gap-3">
<span className="text-[9px] font-mono text-gray-700">
{sidebarSize}PX
</span>
<input
type="range"
min="8"
max="60"
value={sidebarSize}
onChange={(e) =>
setSidebarSize(parseInt(e.target.value))
}
className="w-20 accent-white h-1 bg-gray-800 rounded-lg appearance-none cursor-pointer"
/>
</div>
</div>
<input
type="text"
value={sidebarText}
onChange={(e) => setSidebarText(e.target.value)}
className="w-full bg-black/40 border border-white/10 p-3 font-mono text-xs uppercase tracking-widest focus:border-emerald-500 outline-none transition-all"
/>
</div>
{/* Footer Config */}
<div className="space-y-4">
<div className="flex justify-between items-center">
<label className="block font-mono text-[9px] uppercase text-gray-600">
Bottom_Registry
</label>
<div className="flex items-center gap-3">
<span className="text-[9px] font-mono text-gray-700">
{footerSize}PX
</span>
<input
type="range"
min="8"
max="60"
value={footerSize}
onChange={(e) =>
setFooterSize(parseInt(e.target.value))
}
className="w-20 accent-white h-1 bg-gray-800 rounded-lg appearance-none cursor-pointer"
/>
</div>
</div>
<input
type="text"
value={footerText}
onChange={(e) => setFooterText(e.target.value)}
className="w-full bg-black/40 border border-white/10 p-3 font-mono text-xs uppercase tracking-widest focus:border-emerald-500 outline-none transition-all"
/>
</div>
</div>
</div>
{/* Visual Filters */}
<div className="border border-white/10 bg-white/[0.02] p-8 rounded-sm space-y-10">
<h3 className="font-mono text-[10px] font-bold text-emerald-500 uppercase tracking-widest flex items-center gap-2 border-b border-white/5 pb-6">
<PaintBrush weight="fill" />
Diffusion_Filters
</h3>
<div className="space-y-8">
<div className="space-y-4">
<div className="flex justify-between font-mono text-[9px] uppercase text-gray-600">
<span>Noise_Entropy</span>
<span>{Math.round(noiseOpacity * 100)}%</span>
</div>
<input
type="range"
min="0"
max="0.5"
step="0.01"
value={noiseOpacity}
onChange={(e) =>
setNoiseOpacity(parseFloat(e.target.value))
}
className="w-full accent-white h-1 bg-gray-800 rounded-lg appearance-none cursor-pointer"
/>
</div>
<div className="space-y-4">
<div className="flex justify-between font-mono text-[9px] uppercase text-gray-600">
<span>Grid_Structural</span>
<span>{Math.round(gridOpacity * 100)}%</span>
</div>
<input
type="range"
min="0"
max="0.8"
step="0.01"
value={gridOpacity}
onChange={(e) => setGridOpacity(parseFloat(e.target.value))}
className="w-full accent-white h-1 bg-gray-800 rounded-lg appearance-none cursor-pointer"
/>
</div>
<button
onClick={() => setSeed(Math.random())}
className="w-full py-4 border border-white/10 text-gray-500 hover:text-white hover:bg-white/5 transition-all font-mono text-[10px] uppercase tracking-widest flex items-center justify-center gap-2"
>
<ArrowsClockwise weight="bold" /> Mutate Entities
</button>
</div>
</div>
</div>
{/* RIGHT: Preview */}
<div className="lg:col-span-8">
<div className="relative border border-white/10 bg-[#0a0a0a] rounded-sm overflow-hidden flex items-center justify-center shadow-2xl group min-h-[800px]">
<canvas
ref={canvasRef}
className="w-full max-w-[500px] aspect-[2/3] object-contain shadow-[0_0_100px_rgba(0,0,0,0.5)]"
style={{ imageRendering: 'pixelated' }}
/>
<div className="absolute top-8 right-8 z-30 opacity-0 group-hover:opacity-100 transition-opacity duration-500">
<button
onClick={() => {
setHeaderText('FEZCODEX');
setSubHeaderText('NULL');
setSeed(Math.random());
}}
className="flex items-center gap-2 px-4 py-2 bg-black/60 backdrop-blur-md border border-white/10 text-[10px] font-mono uppercase tracking-widest text-red-400 hover:bg-red-500 hover:text-black transition-all"
>
<Trash weight="bold" /> Reset Template
</button>
</div>
</div>
<div className="mt-12 p-8 border border-white/10 bg-white/[0.01] rounded-sm flex items-start gap-6">
<Info size={32} className="text-gray-700 shrink-0 mt-1" />
<p className="text-sm font-mono uppercase tracking-[0.2em] leading-relaxed text-gray-500 max-w-4xl">
Poster construct utilizes localized Canvas protocols. Final
master generation executes at 2160x3240 resolution to ensure
systemic clarity across all physical and digital displays.
</p>
</div>
</div>
</div>
<footer className="mt-32 pt-12 border-t border-white/10 flex flex-col md:flex-row justify-between items-center gap-6 text-gray-600 font-mono text-[10px] uppercase tracking-[0.3em]">
<span>Fezcodex_Graphic_Construct_v0.6.1</span>
<span className="text-gray-800">CONSTRUCT_STATUS // OPTIMAL</span>
</footer>
</div>
</div>
);
};
export default PosterLoomPage;