-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMagazinerPage.jsx
More file actions
1312 lines (1254 loc) · 46 KB
/
MagazinerPage.jsx
File metadata and controls
1312 lines (1254 loc) · 46 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
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import React, { useState, useRef, useEffect, useCallback } from 'react';
import { Link } from 'react-router-dom';
import {
ArrowLeftIcon,
TrashIcon,
ArrowsClockwiseIcon,
TextAaIcon,
SelectionIcon,
InfoIcon,
DownloadSimpleIcon,
PaintBrushIcon,
ImageIcon,
ArrowsOutIcon,
PushPinIcon,
FloppyDiskBackIcon,
PlusIcon,
SquareIcon,
} from '@phosphor-icons/react';
import Seo from '../../components/Seo';
import { useToast } from '../../hooks/useToast';
import CustomDropdown from '../../components/CustomDropdown';
import CustomSlider from '../../components/CustomSlider';
import BrutalistDialog from '../../components/BrutalistDialog';
import BreadcrumbTitle from '../../components/BreadcrumbTitle';
import CustomColorPicker from '../../components/CustomColorPicker';
const STYLES = [
{ value: 'brutalist', label: 'BRUTALIST_CHAOS' },
{ value: 'posh', label: 'ELITE_AND_POSH' },
{ value: 'glassy', label: 'GLASSY_FLUX' },
];
const FONTS = [
{ value: 'JetBrains Mono', label: 'JETBRAINS_MONO' },
{ value: 'Space Mono', label: 'SPACE_MONO' },
{ value: 'Playfair Display', label: 'PLAYFAIR_DISPLAY' },
{ value: 'Arvo', label: 'ARVO_SERIF' },
{ value: 'Inter', label: 'INTER_SANS' },
];
const PATTERNS = [
{ value: 'just_shapes', label: 'JUST_SHAPES' },
{ value: 'generative_art', label: 'GENERATIVE_ART' },
{ value: 'bauhaus', label: 'BAUHAUS_GRID' },
{ value: 'technical', label: 'TECH_SPEC' },
{ value: 'minimal', label: 'THE_VOID' },
{ value: 'column', label: 'THE_COLUMN' },
{ value: 'diagonal', label: 'DIAGONAL_SCAN' },
];
const COLORS = [
{ name: 'Pure Void', hex: '#050505', text: '#FFFFFF' },
{ name: 'Paper White', hex: '#F5F5F5', text: '#000000' },
{ 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: 'Royal Gold', hex: '#D4AF37', text: '#000000' },
];
const initialInputs = {
issueNo: {
text: 'ISSUE NO. 42',
x: 5,
y: 5,
size: 14,
font: 'JetBrains Mono',
},
title: { text: 'FEZCODEX', x: 50, y: 15, size: 80, font: 'JetBrains Mono' },
subtitle: {
text: 'THE FUTURE OF DIGITAL ARCHITECTURE',
x: 50,
y: 22,
size: 18,
font: 'JetBrains Mono',
},
mainStory: {
text: 'CHAOS THEORY',
x: 10,
y: 45,
size: 50,
font: 'JetBrains Mono',
},
mainStorySub: {
text: 'HOW BRUTALISM SAVED THE WEB',
x: 10,
y: 52,
size: 16,
font: 'JetBrains Mono',
},
secondStory: {
text: 'THE POSH ERA',
x: 90,
y: 70,
size: 30,
font: 'JetBrains Mono',
},
secondStorySub: {
text: 'MINIMALISM IS FOR THE ELITE',
x: 90,
y: 75,
size: 14,
font: 'JetBrains Mono',
},
bottomText: {
text: 'WWW.FEZCODEX.COM // 2025',
x: 50,
y: 95,
size: 12,
font: 'JetBrains Mono',
},
rightEdgeText: {
text: 'CLASSIFIED // NODE 049',
x: 98,
y: 50,
size: 10,
font: 'JetBrains Mono',
},
bottomLeftText: {
text: 'DESIGNED BY FEZCODE',
x: 5,
y: 95,
size: 10,
font: 'JetBrains Mono',
},
};
const MagazinerPage = () => {
const { addToast } = useToast();
const canvasRef = useRef(null);
const fileInputRef = useRef(null);
// Magazine State
const [style, setStyle] = useState('brutalist');
const [pattern, setPattern] = useState('just_shapes');
const [primaryColor, setPrimaryColor] = useState(COLORS[0]);
const [accentColor, setAccentColor] = useState(COLORS[1]);
const [bgImage, setBgImage] = useState(null);
const [seed, setSeed] = useState(Math.random());
const [noiseOpacity, setNoiseOpacity] = useState(0.05);
const [gridOpacity, setGridOpacity] = useState(0.1);
const [shapesOpacity, setShapesOpacity] = useState(0.3);
const [shapesCount, setShapesCount] = useState(15);
const [borderWidth, setBorderWidth] = useState(10);
const [inputs, setInputs] = useState(initialInputs);
const [assets, setAssets] = useState([]);
const [isSaveDialogOpen, setIsSaveDialogOpen] = useState(false);
const [isLoadDialogOpen, setIsLoadDialogOpen] = useState(false);
const [isExportDialogOpen, setIsExportDialogOpen] = useState(false);
const [stickyPreview, setStickyPreview] = useState(true);
const addAsset = (type) => {
const newAsset = {
id: Date.now(),
type,
x: 50,
y: 50,
width: type === 'line' ? 20 : 10,
height: type === 'line' ? 0.5 : 10,
rotation: 0,
opacity: 1,
};
setAssets([...assets, newAsset]);
addToast({
title: 'ASSET_ADDED',
message: `New ${type.toUpperCase()} entity initialized.`,
});
};
const updateAsset = (id, field, value) => {
setAssets(assets.map((a) => (a.id === id ? { ...a, [field]: value } : a)));
};
const removeAsset = (id) => {
setAssets(assets.filter((a) => a.id !== id));
addToast({
title: 'ASSET_REMOVED',
message: 'Entity purged from current sequence.',
type: 'info',
});
};
const handleSavePreset = () => {
const preset = {
style,
pattern,
primaryColor,
accentColor,
noiseOpacity,
gridOpacity,
shapesOpacity,
shapesCount,
borderWidth,
inputs,
assets,
};
localStorage.setItem('magaziner_preset', JSON.stringify(preset));
addToast({
title: 'PRESET_SAVED',
message: 'Current configuration stored in local memory.',
});
};
const handleLoadPreset = () => {
const saved = localStorage.getItem('magaziner_preset');
if (saved) {
try {
const preset = JSON.parse(saved);
setStyle(preset.style);
setPattern(preset.pattern);
setPrimaryColor(preset.primaryColor);
setAccentColor(preset.accentColor);
setNoiseOpacity(preset.noiseOpacity);
setGridOpacity(preset.gridOpacity);
setShapesOpacity(preset.shapesOpacity);
setShapesCount(preset.shapesCount);
setBorderWidth(preset.borderWidth);
setInputs(preset.inputs);
if (preset.assets) setAssets(preset.assets);
addToast({
title: 'PRESET_LOADED',
message: 'Configuration successfully restored.',
});
} catch (e) {
addToast({
title: 'LOAD_ERROR',
message: 'Stored preset is corrupted or incompatible.',
type: 'error',
});
}
} else {
addToast({
title: 'NO_PRESET',
message: 'No stored configuration found in local memory.',
type: 'info',
});
}
};
useEffect(() => {
if (style === 'posh') {
setInputs((prev) => ({
...prev,
issueNo: { ...prev.issueNo, font: 'Playfair Display', size: 12 },
title: { ...prev.title, font: 'Playfair Display', size: 100 },
subtitle: { ...prev.subtitle, font: 'Inter', size: 14 },
mainStory: { ...prev.mainStory, font: 'Playfair Display', size: 40 },
mainStorySub: { ...prev.mainStorySub, font: 'Inter', size: 12 },
secondStory: {
...prev.secondStory,
font: 'Playfair Display',
size: 24,
},
secondStorySub: { ...prev.secondStorySub, font: 'Inter', size: 10 },
bottomText: { ...prev.bottomText, font: 'Inter', size: 10 },
rightEdgeText: { ...prev.rightEdgeText, font: 'Inter', size: 8 },
bottomLeftText: { ...prev.bottomLeftText, font: 'Inter', size: 8 },
}));
setPrimaryColor(COLORS[1]);
setAccentColor(COLORS[0]);
} else if (style === 'glassy') {
setInputs((prev) => ({
...prev,
issueNo: { ...prev.issueNo, font: 'JetBrains Mono', size: 12 },
title: { ...prev.title, font: 'Playfair Display', size: 100 },
subtitle: { ...prev.subtitle, font: 'JetBrains Mono', size: 14 },
mainStory: { ...prev.mainStory, font: 'Arvo', size: 45 },
mainStorySub: {
...prev.mainStorySub,
font: 'JetBrains Mono',
size: 12,
},
secondStory: {
...prev.secondStory,
font: 'Playfair Display',
size: 24,
},
secondStorySub: {
...prev.secondStorySub,
font: 'JetBrains Mono',
size: 10,
},
bottomText: { ...prev.bottomText, font: 'JetBrains Mono', size: 10 },
rightEdgeText: {
...prev.rightEdgeText,
font: 'JetBrains Mono',
size: 8,
},
bottomLeftText: {
...prev.bottomLeftText,
font: 'JetBrains Mono',
size: 8,
},
}));
setPrimaryColor({
name: 'Glassy Indigo',
hex: '#6366f1',
text: '#FFFFFF',
});
setAccentColor({ name: 'White', hex: '#FFFFFF', text: '#000000' });
setPattern('generative_art');
} else {
setInputs(initialInputs);
setPrimaryColor(COLORS[0]);
setAccentColor(COLORS[2]);
}
}, [style]);
const handleInputChange = (key, field, value) => {
setInputs((prev) => ({
...prev,
[key]: { ...prev[key], [field]: value },
}));
};
const handleImageUpload = (e) => {
const file = e.target.files[0];
if (file) {
const reader = new FileReader();
reader.onload = (event) => {
const img = new Image();
img.onload = () => setBgImage(img);
img.src = event.target.result;
};
reader.readAsDataURL(file);
}
};
const drawMagazine = useCallback(
(
ctx,
width,
height,
options = { includeText: true, includeBgImage: true },
) => {
const scale = width / 1000;
const rng = (s) => {
let v = s * 12345.678;
return () => {
v = (v * 987.654) % 1;
return v;
};
};
const getRand = rng(seed);
// 1. Background
ctx.fillStyle = primaryColor.hex;
ctx.fillRect(0, 0, width, height);
if (style === 'glassy' && !bgImage) {
const bgGradient = ctx.createLinearGradient(0, 0, width, height);
bgGradient.addColorStop(0, '#6366f1');
bgGradient.addColorStop(0.5, '#a855f7');
bgGradient.addColorStop(1, '#ec4899');
ctx.fillStyle = bgGradient;
ctx.fillRect(0, 0, width, height);
const drawBlob = (x, y, r, color) => {
ctx.save();
ctx.beginPath();
ctx.arc(x, y, r, 0, Math.PI * 2);
ctx.fillStyle = color;
ctx.filter = 'blur(80px)';
ctx.globalAlpha = 0.4;
ctx.fill();
ctx.restore();
};
drawBlob(width * 0.2, height * 0.2, 300 * scale, '#c084fc');
drawBlob(width * 0.8, height * 0.1, 250 * scale, '#facc15');
drawBlob(width * 0.5, height * 0.9, 350 * scale, '#f472b6');
}
if (bgImage && options.includeBgImage) {
const imgRatio = bgImage.width / bgImage.height;
const canvasRatio = width / height;
let dWidth, dHeight, dx, dy;
if (imgRatio > canvasRatio) {
dHeight = height;
dWidth = height * imgRatio;
dx = (width - dWidth) / 2;
dy = 0;
} else {
dWidth = width;
dHeight = width / imgRatio;
dx = 0;
dy = (height - dHeight) / 2;
}
ctx.drawImage(bgImage, dx, dy, dWidth, dHeight);
}
// 2. Grid Layer (Structural Protocol)
if (gridOpacity > 0) {
ctx.save();
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.restore();
}
// 3. Shapes & Patterns
ctx.save();
ctx.strokeStyle = accentColor.hex;
ctx.fillStyle = accentColor.hex;
ctx.lineWidth = 1 * scale;
if (pattern === 'just_shapes') {
for (let i = 0; i < shapesCount; i++) {
const shapeType = Math.floor(getRand() * 10);
const x = getRand() * width;
const y = getRand() * height;
const size = (20 + getRand() * 100) * scale;
ctx.globalAlpha = shapesOpacity;
switch (shapeType) {
case 0:
ctx.strokeRect(x, y, size, size);
break;
case 1:
ctx.beginPath();
ctx.arc(x, y, size / 2, 0, Math.PI * 2);
ctx.stroke();
break;
case 2:
ctx.beginPath();
ctx.moveTo(x, y);
ctx.lineTo(x + size, y);
ctx.lineTo(x + size / 2, y - size);
ctx.closePath();
ctx.stroke();
break;
case 3:
ctx.beginPath();
ctx.moveTo(x - size / 2, y);
ctx.lineTo(x + size / 2, y);
ctx.moveTo(x, y - size / 2);
ctx.lineTo(x, y + size / 2);
ctx.stroke();
break;
case 4:
const gSize = size / 4;
for (let gx = 0; gx < 4; gx++) {
for (let gy = 0; gy < 4; gy++) {
ctx.strokeRect(x + gx * gSize, y + gy * gSize, 2, 2);
}
}
break;
case 5:
for (let j = 0; j < 5; j++) {
ctx.beginPath();
ctx.arc(
x + getRand() * size,
y + getRand() * size,
2 * scale,
0,
Math.PI * 2,
);
ctx.fill();
}
break;
case 6:
ctx.beginPath();
ctx.moveTo(x, y);
for (let j = 0; j < size; j += 5) {
ctx.lineTo(x + j, y + Math.sin(j * 0.1) * 10 * scale);
}
ctx.stroke();
break;
case 7:
ctx.beginPath();
ctx.moveTo(x, y);
ctx.lineTo(x + size, y + size);
ctx.stroke();
break;
case 8:
ctx.beginPath();
for (let j = 0; j < 5; j++) {
ctx.lineTo(
x + Math.cos((j * Math.PI * 2) / 5) * size,
y + Math.sin((j * Math.PI * 2) / 5) * size,
);
}
ctx.closePath();
ctx.stroke();
break;
case 9:
ctx.beginPath();
ctx.arc(x, y, size / 2, 0, Math.PI * 2);
ctx.stroke();
ctx.beginPath();
ctx.arc(x, y, size / 4, 0, Math.PI * 2);
ctx.stroke();
break;
default:
break;
}
}
} else if (pattern === 'generative_art') {
const artRng = (s) => {
let h = 0xdeadbeef;
const safeSeed = s.toString();
for (let i = 0; i < safeSeed.length; i++) {
h = Math.imul(h ^ safeSeed.charCodeAt(i), 2654435761);
}
return () => {
h = Math.imul(h ^ (h >>> 16), 2246822507);
h = Math.imul(h ^ (h >>> 13), 3266489909);
return ((h ^= h >>> 16) >>> 0) / 4294967296;
};
};
const gRng = artRng(seed);
const type = Math.floor(gRng() * 3);
ctx.globalAlpha = shapesOpacity;
if (type === 0) {
const gridSize = 5;
const cellSize = width / gridSize;
for (let x = 0; x < gridSize; x++) {
for (let y = 0; y < gridSize; y++) {
if (gRng() > 0.5) {
const shapeType = Math.floor(gRng() * 4);
const rotation = Math.floor(gRng() * 4) * (Math.PI / 2);
const cx = x * cellSize + cellSize / 2;
const cy = y * cellSize + cellSize / 2;
const is = cellSize * 0.8;
const p = cellSize * 0.1;
ctx.save();
ctx.translate(cx, cy);
ctx.rotate(rotation);
ctx.translate(-cellSize / 2, -cellSize / 2);
if (shapeType === 0) ctx.strokeRect(p, p, is, is);
else if (shapeType === 1) {
ctx.beginPath();
ctx.arc(cellSize / 2, cellSize / 2, is / 2, 0, Math.PI * 2);
ctx.stroke();
} else if (shapeType === 2) {
ctx.beginPath();
ctx.moveTo(p, p);
ctx.lineTo(cellSize - p, p);
ctx.arcTo(cellSize - p, cellSize - p, p, cellSize - p, is);
ctx.lineTo(p, p);
ctx.stroke();
} else if (shapeType === 3) {
ctx.beginPath();
ctx.moveTo(p, cellSize - p);
ctx.lineTo(cellSize / 2, p);
ctx.lineTo(cellSize - p, cellSize - p);
ctx.closePath();
ctx.stroke();
}
ctx.restore();
}
}
}
} else if (type === 1) {
for (let i = 0; i < 15; i++) {
const isVertical = gRng() > 0.5;
const x = Math.floor(gRng() * 10) * (width / 10);
const y = Math.floor(gRng() * 10) * (height / 10);
const thickness = (0.5 + gRng() * 1.5) * scale * 5;
const len = (20 + gRng() * 60) * scale * 5;
ctx.fillRect(
x,
y,
isVertical ? thickness : len,
isVertical ? len : thickness,
);
if (gRng() > 0.4) {
ctx.beginPath();
ctx.arc(x, y, thickness * 2, 0, Math.PI * 2);
ctx.fill();
}
}
} else {
for (let i = 0; i < 8; i++) {
const cx = gRng() * width;
const cy = gRng() * height;
const r = (10 + gRng() * 40) * scale * 5;
ctx.beginPath();
ctx.arc(cx, cy, r, 0, Math.PI * 2);
ctx.fill();
}
}
} else {
const padding = 60 * scale;
ctx.globalAlpha = shapesOpacity;
ctx.lineWidth = 2 * scale;
if (pattern === '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 (pattern === '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 (pattern === 'minimal') {
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 (pattern === 'column') {
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 (pattern === 'diagonal') {
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();
// 4. Manual Assets (Structural Entities)
ctx.save();
assets.forEach((asset) => {
ctx.save();
const ax = (asset.x / 100) * width;
const ay = (asset.y / 100) * height;
const aw = (asset.width / 100) * width;
const ah = (asset.height / 100) * height;
ctx.translate(ax, ay);
ctx.rotate(asset.rotation * (Math.PI / 180));
ctx.globalAlpha = asset.opacity;
ctx.fillStyle = accentColor.hex;
ctx.strokeStyle = accentColor.hex;
ctx.lineWidth = 1 * scale;
if (asset.type === 'line') {
ctx.fillRect(-aw / 2, -ah / 2, aw, ah);
} else if (asset.type === 'box') {
ctx.strokeRect(-aw / 2, -ah / 2, aw, ah);
}
ctx.restore();
});
ctx.restore();
// 5. Typography
if (options.includeText) {
ctx.fillStyle = accentColor.hex;
ctx.textBaseline = 'middle';
Object.entries(inputs).forEach(([key, config]) => {
ctx.save();
ctx.font = `${style === 'brutalist' ? 'bold' : ''} ${config.size * scale}px "${config.font}"`;
const x = (config.x / 100) * width;
const y = (config.y / 100) * height;
if (key === 'rightEdgeText') {
ctx.translate(x, y);
ctx.rotate(Math.PI / 2);
ctx.textAlign = 'center';
ctx.fillText(config.text.toUpperCase(), 0, 0);
} else if (
key === 'title' ||
key === 'subtitle' ||
key === 'bottomText'
) {
ctx.textAlign = 'center';
ctx.fillText(config.text.toUpperCase(), x, y);
} else if (key === 'secondStory' || key === 'secondStorySub') {
ctx.textAlign = 'right';
ctx.fillText(config.text.toUpperCase(), x, y);
} else {
ctx.textAlign = 'left';
ctx.fillText(config.text.toUpperCase(), x, y);
}
ctx.restore();
});
}
// 4. Border
if (borderWidth > 0) {
ctx.strokeStyle = accentColor.hex;
ctx.lineWidth = borderWidth * scale;
const bPadding = 30 * scale;
if (style === 'glassy') {
const r = 40 * scale;
const bx = bPadding;
const by = bPadding;
const bw = width - bPadding * 2;
const bh = height - bPadding * 2;
ctx.beginPath();
ctx.moveTo(bx + r, by);
ctx.lineTo(bx + bw - r, by);
ctx.quadraticCurveTo(bx + bw, by, bx + bw, by + r);
ctx.lineTo(bx + bw, by + bh - r);
ctx.quadraticCurveTo(bx + bw, by + bh, bx + bw - r, by + bh);
ctx.lineTo(bx + r, by + bh);
ctx.quadraticCurveTo(bx, by + bh, bx, by + bh - r);
ctx.lineTo(bx, by + r);
ctx.quadraticCurveTo(bx, by, bx + r, by);
ctx.closePath();
ctx.stroke();
} else {
ctx.strokeRect(
bPadding,
bPadding,
width - bPadding * 2,
height - bPadding * 2,
);
}
}
// 5. Noise
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();
}
},
[
style,
pattern,
primaryColor,
accentColor,
bgImage,
seed,
shapesCount,
shapesOpacity,
noiseOpacity,
gridOpacity,
borderWidth,
inputs,
assets,
],
);
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);
drawMagazine(ctx, rect.width, rect.height);
}, [drawMagazine]);
const handleDownload = (mode = 'full') => {
const canvas = document.createElement('canvas');
const ctx = canvas.getContext('2d');
const W = 2480;
const H = 3508;
canvas.width = W;
canvas.height = H;
const options = {
includeText: mode === 'full',
includeBgImage: mode === 'full',
};
drawMagazine(ctx, W, H, options);
const link = document.createElement('a');
link.download = `magaziner-${mode}-${Date.now()}.png`;
link.href = canvas.toDataURL('image/png', 1.0);
link.click();
addToast({
title: 'EXPORT_SUCCESS',
message:
mode === 'full'
? 'Magazine cover exported.'
: 'Background template exported.',
});
};
return (
<div className="min-h-screen bg-[#050505] text-white selection:bg-emerald-500/30 font-sans">
<Seo
title="Magaziner | Fezcodex"
description="Generate high-end magazine covers with brutalist or posh aesthetics."
keywords={[
'Fezcodex',
'magazine cover generator',
'brutalist design',
'posh design',
'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]"
>
<ArrowLeftIcon 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">
<BreadcrumbTitle
title="Magaziner"
slug="magaziner"
variant="brutalist"
/>
<p className="text-xl text-gray-400 max-w-2xl font-light leading-relaxed">
Premium cover construction interface. Toggle between raw
brutalism and elite minimal aesthetics.
</p>
</div>
<div className="flex gap-4">
<button
onClick={() => setIsLoadDialogOpen(true)}
className="p-6 border border-white/10 text-emerald-500 hover:text-white hover:bg-white/5 transition-all rounded-sm"
title="Load Stored Preset"
>
<ArrowsClockwiseIcon weight="bold" size={24} />
</button>
<button
onClick={() => setIsSaveDialogOpen(true)}
className="p-6 border border-white/10 text-emerald-500 hover:text-white hover:bg-white/5 transition-all rounded-sm"
title="Save Current Preset"
>
<FloppyDiskBackIcon weight="bold" size={24} />
</button>
<button
onClick={() => setIsExportDialogOpen(true)}
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"
>
<DownloadSimpleIcon weight="bold" size={24} />
<span>Export</span>
</button>
</div>
</div>
</header>
<BrutalistDialog
isOpen={isSaveDialogOpen}
onClose={() => setIsSaveDialogOpen(false)}
onConfirm={() => {
handleSavePreset();
setIsSaveDialogOpen(false);
}}
title="MEMORY_COMMIT_PROTOCOL"
message="THIS ACTION WILL OVERWRITE YOUR PREVIOUSLY STORED CONFIGURATION IN THE LOCAL BROWSER ARCHIVE. DO YOU WISH TO COMMIT THESE ENTITIES?"
confirmText="COMMIT_TO_MEMORY"
cancelText="ABORT_SEQUENCE"
/>
<BrutalistDialog
isOpen={isLoadDialogOpen}
onClose={() => setIsLoadDialogOpen(false)}
onConfirm={() => {
handleLoadPreset();
setIsLoadDialogOpen(false);
}}
title="DATA_RECOVERY_PROTOCOL"
message="THIS ACTION WILL OVERRIDE ALL CURRENT UNSAVED CHANGES WITH THE DATA STORED IN YOUR LOCAL ARCHIVE. DO YOU WISH TO PROCEED WITH RECOVERY?"
confirmText="EXECUTE_RECOVERY"
cancelText="ABORT_SEQUENCE"
/>
<BrutalistDialog
isOpen={isExportDialogOpen}
onClose={() => setIsExportDialogOpen(false)}
title="EXPORT_MANAGER_v1.0"
>
<div className="space-y-6 font-mono text-sm uppercase tracking-wider">
<p className="text-gray-500 text-xs leading-relaxed">
SELECT EXPORT MODE FOR CURRENT ARCHIVE ENTITY:
</p>
<div className="flex flex-col gap-4">
<button
onClick={() => {
handleDownload('full');
setIsExportDialogOpen(false);
}}
className="w-full py-6 bg-white text-black hover:bg-emerald-500 transition-all font-black text-xs flex flex-col items-center gap-1"
>
<span>EXPORT_COVER</span>
<span className="text-[9px] opacity-60">
FULL COMPOSITION WITH TYPOGRAPHY & MEDIA
</span>
</button>
<button
onClick={() => {
handleDownload('page');
setIsExportDialogOpen(false);
}}
className="w-full py-6 border border-white/10 text-white hover:bg-white/5 transition-all font-black text-xs flex flex-col items-center gap-1"
>
<span>EXPORT_PAGE</span>
<span className="text-[9px] text-gray-500">
TEMPLATE ONLY // SHAPES + GRID + BORDER
</span>
</button>
<button
onClick={() => setIsExportDialogOpen(false)}
className="w-full py-3 text-red-500 hover:text-white transition-all font-mono text-[10px] uppercase tracking-[0.3em]"
>
[ CLOSE_SESSION ]
</button>
</div>
</div>
</BrutalistDialog>
<div className="grid grid-cols-1 lg:grid-cols-12 gap-12">
<div className="lg:col-span-4 space-y-8">
<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">
<SelectionIcon weight="fill" />
Aesthetic_Profile
</h3>
<div className="space-y-6">
<CustomDropdown
label="Style Protocol"
options={STYLES}
value={style}
onChange={setStyle}
variant="brutalist"
fullWidth
/>
<div className="space-y-4">
<label className="block font-mono text-[9px] uppercase text-gray-600">
Background Image
</label>
<input
type="file"
ref={fileInputRef}
onChange={handleImageUpload}
className="hidden"
accept="image/*"
/>
<button
onClick={() => fileInputRef.current.click()}
className="w-full py-3 border border-dashed border-white/20 text-gray-400 hover:text-white transition-all font-mono text-[10px] uppercase flex items-center justify-center gap-2"
>
<ImageIcon weight="bold" />{' '}
{bgImage ? 'Replace Image' : 'Upload Backdrop'}
</button>
{bgImage && (
<button
onClick={() => setBgImage(null)}
className="w-full text-[9px] font-mono text-red-500 uppercase text-center"
>
Clear Image