@clypra-studio/engine 1.2.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -39
- package/dist/{chunk-LT3HTJ3X.js → chunk-3UEOLDJJ.js} +5 -829
- package/dist/chunk-3UEOLDJJ.js.map +1 -0
- package/dist/{chunk-Y4FMAOTW.js → chunk-E6O6LZME.js} +266 -1004
- package/dist/chunk-E6O6LZME.js.map +1 -0
- package/dist/chunk-PU3Q4QI7.js +833 -0
- package/dist/chunk-PU3Q4QI7.js.map +1 -0
- package/dist/{index-D6GAXDBy.d.cts → index-C18SQ-y6.d.cts} +171 -37
- package/dist/{index-D6GAXDBy.d.ts → index-C18SQ-y6.d.ts} +171 -37
- package/dist/index.cjs +12064 -19908
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3302 -7641
- package/dist/index.d.ts +3302 -7641
- package/dist/index.js +11201 -14606
- package/dist/index.js.map +1 -1
- package/dist/textEffects/index.cjs +259 -971
- package/dist/textEffects/index.cjs.map +1 -1
- package/dist/textEffects/index.d.cts +1 -1
- package/dist/textEffects/index.d.ts +1 -1
- package/dist/textEffects/index.js +1 -1
- package/dist/transitions/index.cjs +18 -2199
- package/dist/transitions/index.cjs.map +1 -1
- package/dist/transitions/index.d.cts +37 -53
- package/dist/transitions/index.d.ts +37 -53
- package/dist/transitions/index.js +3 -51
- package/dist/videoEffects/index.cjs +4 -835
- package/dist/videoEffects/index.cjs.map +1 -1
- package/dist/videoEffects/index.d.cts +9 -138
- package/dist/videoEffects/index.d.ts +9 -138
- package/dist/videoEffects/index.js +1 -15
- package/package.json +14 -17
- package/dist/TransitionDefinition-CQoSb4ZB.d.cts +0 -158
- package/dist/TransitionDefinition-CQoSb4ZB.d.ts +0 -158
- package/dist/chunk-FIJBB3MH.js +0 -2990
- package/dist/chunk-FIJBB3MH.js.map +0 -1
- package/dist/chunk-LT3HTJ3X.js.map +0 -1
- package/dist/chunk-RYA4KGDB.js +0 -690
- package/dist/chunk-RYA4KGDB.js.map +0 -1
- package/dist/chunk-Y4FMAOTW.js.map +0 -1
- package/dist/index-Da47I6aX.d.cts +0 -139
- package/dist/index-Da47I6aX.d.ts +0 -139
- package/dist/v2/backends/index.cjs +0 -693
- package/dist/v2/backends/index.cjs.map +0 -1
- package/dist/v2/backends/index.d.cts +0 -3
- package/dist/v2/backends/index.d.ts +0 -3
- package/dist/v2/backends/index.js +0 -8
- package/dist/v2/backends/index.js.map +0 -1
|
@@ -1,20 +1,15 @@
|
|
|
1
1
|
// src/engine/schema.ts
|
|
2
2
|
var SCENE_VERSION = 1;
|
|
3
|
+
var SCENE_SCHEMA_VERSION = 2;
|
|
3
4
|
var DEFAULT_CANVAS_WIDTH = 800;
|
|
4
5
|
var DEFAULT_CANVAS_HEIGHT = 200;
|
|
5
6
|
var DEFAULT_FONT_SIZE = 80;
|
|
6
7
|
var DEFAULT_FPS = 30;
|
|
7
8
|
var DEFAULT_DURATION = 2;
|
|
8
|
-
var CUSTOM_ENGINE_IDS = ["ink"];
|
|
9
|
-
var LEGACY_RENDERER_MAP = {
|
|
10
|
-
InkBrushEngine: "ink"
|
|
11
|
-
};
|
|
12
|
-
var ENGINE_ID_TO_LEGACY = {
|
|
13
|
-
ink: "InkBrushEngine"
|
|
14
|
-
};
|
|
15
9
|
function createEmptyScene(overrides) {
|
|
16
10
|
return {
|
|
17
11
|
version: SCENE_VERSION,
|
|
12
|
+
schemaVersion: SCENE_SCHEMA_VERSION,
|
|
18
13
|
effectName: "My Effect",
|
|
19
14
|
canvas: { width: DEFAULT_CANVAS_WIDTH, height: DEFAULT_CANVAS_HEIGHT, background: "transparent" },
|
|
20
15
|
text: {
|
|
@@ -29,7 +24,6 @@ function createEmptyScene(overrides) {
|
|
|
29
24
|
textPosY: "middle"
|
|
30
25
|
},
|
|
31
26
|
effectLayers: [],
|
|
32
|
-
customEngineId: null,
|
|
33
27
|
compositor: { blur: 0, bloom: 0, bloomThreshold: 0.6 },
|
|
34
28
|
timeline: { duration: DEFAULT_DURATION, fps: DEFAULT_FPS, loop: true, tracks: [] },
|
|
35
29
|
...overrides
|
|
@@ -271,7 +265,7 @@ function drawPerCharText(ctx, opts) {
|
|
|
271
265
|
ctx.restore();
|
|
272
266
|
}
|
|
273
267
|
function shouldUsePerCharFill(cfg) {
|
|
274
|
-
return !!cfg.perCharFillEnabled && cfg.fillType === "solid" &&
|
|
268
|
+
return !!cfg.perCharFillEnabled && cfg.fillType === "solid" && (cfg.charFillColors?.length ?? 0) > 0;
|
|
275
269
|
}
|
|
276
270
|
|
|
277
271
|
// src/platform.ts
|
|
@@ -279,7 +273,6 @@ var _ctxFilter = null;
|
|
|
279
273
|
var _roundRect = null;
|
|
280
274
|
var _letterSpacing = null;
|
|
281
275
|
var _offscreenCanvas = null;
|
|
282
|
-
var _webgl2 = null;
|
|
283
276
|
function probe2d() {
|
|
284
277
|
if (typeof document === "undefined") return null;
|
|
285
278
|
try {
|
|
@@ -329,22 +322,6 @@ function supportsOffscreenCanvas() {
|
|
|
329
322
|
_offscreenCanvas = typeof globalThis !== "undefined" && typeof globalThis.OffscreenCanvas === "function";
|
|
330
323
|
return _offscreenCanvas;
|
|
331
324
|
}
|
|
332
|
-
function supportsWebGL2() {
|
|
333
|
-
if (_webgl2 !== null) return _webgl2;
|
|
334
|
-
if (typeof document === "undefined") {
|
|
335
|
-
_webgl2 = false;
|
|
336
|
-
return false;
|
|
337
|
-
}
|
|
338
|
-
try {
|
|
339
|
-
const canvas = document.createElement("canvas");
|
|
340
|
-
canvas.width = 1;
|
|
341
|
-
canvas.height = 1;
|
|
342
|
-
_webgl2 = !!canvas.getContext("webgl2");
|
|
343
|
-
} catch {
|
|
344
|
-
_webgl2 = false;
|
|
345
|
-
}
|
|
346
|
-
return _webgl2;
|
|
347
|
-
}
|
|
348
325
|
function createCanvas(width, height) {
|
|
349
326
|
if (supportsOffscreenCanvas()) {
|
|
350
327
|
return new OffscreenCanvas(width, height);
|
|
@@ -366,7 +343,7 @@ function createCanvas(width, height) {
|
|
|
366
343
|
}
|
|
367
344
|
}
|
|
368
345
|
function releaseCanvas(canvas) {
|
|
369
|
-
if (canvas instanceof OffscreenCanvas) return;
|
|
346
|
+
if (typeof OffscreenCanvas !== "undefined" && canvas instanceof OffscreenCanvas) return;
|
|
370
347
|
canvas.width = 0;
|
|
371
348
|
canvas.height = 0;
|
|
372
349
|
}
|
|
@@ -375,7 +352,6 @@ function _resetPlatformCache() {
|
|
|
375
352
|
_roundRect = null;
|
|
376
353
|
_letterSpacing = null;
|
|
377
354
|
_offscreenCanvas = null;
|
|
378
|
-
_webgl2 = null;
|
|
379
355
|
}
|
|
380
356
|
var CanvasDevice = class {
|
|
381
357
|
static canvases = [];
|
|
@@ -418,363 +394,6 @@ var CanvasDevice = class {
|
|
|
418
394
|
}
|
|
419
395
|
};
|
|
420
396
|
|
|
421
|
-
// src/engine/procedural/utils.ts
|
|
422
|
-
function getCanvas2DContext(canvas) {
|
|
423
|
-
return canvas.getContext("2d");
|
|
424
|
-
}
|
|
425
|
-
function seededRandom(seed) {
|
|
426
|
-
let s = seed;
|
|
427
|
-
return function() {
|
|
428
|
-
s = s * 16807 % 2147483647;
|
|
429
|
-
return (s - 1) / 2147483646;
|
|
430
|
-
};
|
|
431
|
-
}
|
|
432
|
-
function textSeed(text) {
|
|
433
|
-
return text.split("").reduce((acc, c) => acc + c.charCodeAt(0), 0) * 9301 % 49297;
|
|
434
|
-
}
|
|
435
|
-
function hexToRgb(hex) {
|
|
436
|
-
const shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
|
|
437
|
-
const fullHex = hex.replace(shorthandRegex, (m, r, g, b) => r + r + g + g + b + b);
|
|
438
|
-
const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(fullHex);
|
|
439
|
-
return result ? {
|
|
440
|
-
r: parseInt(result[1], 16),
|
|
441
|
-
g: parseInt(result[2], 16),
|
|
442
|
-
b: parseInt(result[3], 16)
|
|
443
|
-
} : { r: 255, g: 255, b: 255 };
|
|
444
|
-
}
|
|
445
|
-
|
|
446
|
-
// src/engine/procedural/InkBrushEngine.ts
|
|
447
|
-
var InkBrushEngine = class {
|
|
448
|
-
cfg;
|
|
449
|
-
bristleLines = [];
|
|
450
|
-
grainDots = [];
|
|
451
|
-
drips = [];
|
|
452
|
-
constructor(config) {
|
|
453
|
-
const defaults = {
|
|
454
|
-
text: "INK",
|
|
455
|
-
effectName: "InkBrush",
|
|
456
|
-
fontFamily: "Bebas Neue",
|
|
457
|
-
fontWeight: 900,
|
|
458
|
-
fontStyle: "italic",
|
|
459
|
-
fontSize: 96,
|
|
460
|
-
letterSpacing: 2,
|
|
461
|
-
lineHeight: 1.1,
|
|
462
|
-
wrapText: true,
|
|
463
|
-
autoFitText: false,
|
|
464
|
-
perCharFillEnabled: false,
|
|
465
|
-
charFillColors: [],
|
|
466
|
-
fillType: "solid",
|
|
467
|
-
fillColor: "#FFFFFF",
|
|
468
|
-
fillGradientAngle: 90,
|
|
469
|
-
fillGradientStops: [],
|
|
470
|
-
patternType: "chalk",
|
|
471
|
-
strokeEnabled: false,
|
|
472
|
-
strokeColor: "#000000",
|
|
473
|
-
strokeWidth: 0,
|
|
474
|
-
strokePosition: "outside",
|
|
475
|
-
strokeOpacity: 100,
|
|
476
|
-
strokeLineJoin: "round",
|
|
477
|
-
strokeBlur: 0,
|
|
478
|
-
strokeType: "single",
|
|
479
|
-
strokeColorSecondary: "#FFFFFF",
|
|
480
|
-
strokeWidthSecondary: 4,
|
|
481
|
-
strokeFadeRange: 0,
|
|
482
|
-
glowLayers: [],
|
|
483
|
-
shadowEnabled: false,
|
|
484
|
-
shadowColor: "#000000",
|
|
485
|
-
shadowBlur: 10,
|
|
486
|
-
shadowOffsetX: 5,
|
|
487
|
-
shadowOffsetY: 5,
|
|
488
|
-
shadowOpacity: 80,
|
|
489
|
-
shadowType: "drop",
|
|
490
|
-
bevelEnabled: false,
|
|
491
|
-
bevelDepth: 5,
|
|
492
|
-
bevelHighlight: "#FFFFFF",
|
|
493
|
-
bevelShadow: "#000000",
|
|
494
|
-
bevelDirection: "bottom-right",
|
|
495
|
-
bevelCoreColor: "#000000",
|
|
496
|
-
bevelEdgeColor: "#2A2A38",
|
|
497
|
-
bevelEdgeWidth: 0,
|
|
498
|
-
bevelBlur: 0,
|
|
499
|
-
bevelBlurColor: "#000000",
|
|
500
|
-
bevelPerspectiveEnabled: false,
|
|
501
|
-
bevelVanishingPointX: 40,
|
|
502
|
-
bevelVanishingPointY: 80,
|
|
503
|
-
bevelFocalLength: 400,
|
|
504
|
-
stackEnabled: false,
|
|
505
|
-
stackCount: 3,
|
|
506
|
-
stackOffsetX: 10,
|
|
507
|
-
stackOffsetY: -10,
|
|
508
|
-
stackOpacityDecay: 20,
|
|
509
|
-
stackColor1: "#FF7C00",
|
|
510
|
-
stackColor2: "#00FFDD",
|
|
511
|
-
stackColor3: "#FF00AA",
|
|
512
|
-
stackColor4: "#AA00FF",
|
|
513
|
-
panelEnabled: false,
|
|
514
|
-
panelColor: "#1E1E26",
|
|
515
|
-
panelOpacity: 80,
|
|
516
|
-
panelRadius: 12,
|
|
517
|
-
panelPaddingX: 40,
|
|
518
|
-
panelPaddingY: 20,
|
|
519
|
-
panelStrokeEnabled: false,
|
|
520
|
-
panelStrokeColor: "#2A2A38",
|
|
521
|
-
panelStrokeWidth: 2,
|
|
522
|
-
canvasWidth: DEFAULT_CANVAS_WIDTH,
|
|
523
|
-
canvasHeight: DEFAULT_CANVAS_HEIGHT,
|
|
524
|
-
textPosX: "center",
|
|
525
|
-
textPosY: "middle",
|
|
526
|
-
inkColor: "#FFFFFF",
|
|
527
|
-
bristleDensity: 0.8,
|
|
528
|
-
bristleSkipRate: 0.2,
|
|
529
|
-
dripRate: 0.3,
|
|
530
|
-
dripMaxLength: 40,
|
|
531
|
-
grainDensity: 0.15,
|
|
532
|
-
skewX: -0.2,
|
|
533
|
-
customRenderer: "InkBrushEngine"
|
|
534
|
-
};
|
|
535
|
-
this.cfg = {
|
|
536
|
-
...defaults,
|
|
537
|
-
...config
|
|
538
|
-
};
|
|
539
|
-
this.precomputeData();
|
|
540
|
-
}
|
|
541
|
-
precomputeData() {
|
|
542
|
-
const { text, fontFamily, fontWeight, fontStyle, fontSize, letterSpacing, lineHeight, canvasWidth, canvasHeight, textPosX, textPosY, bristleDensity, bristleSkipRate, dripRate, dripMaxLength, grainDensity, skewX } = this.cfg;
|
|
543
|
-
const width = canvasWidth;
|
|
544
|
-
const height = canvasHeight;
|
|
545
|
-
const rand = seededRandom(textSeed(text));
|
|
546
|
-
let canvas = createCanvas(width, height);
|
|
547
|
-
canvas.width = width;
|
|
548
|
-
canvas.height = height;
|
|
549
|
-
const ctx = getCanvas2DContext(canvas);
|
|
550
|
-
if (!ctx) return;
|
|
551
|
-
const lines = text.split("\n");
|
|
552
|
-
const numLines = lines.length;
|
|
553
|
-
const textBlockHeight = fontSize + (numLines - 1) * fontSize * lineHeight;
|
|
554
|
-
let startX = width / 2;
|
|
555
|
-
let align = "center";
|
|
556
|
-
if (textPosX === "left") {
|
|
557
|
-
startX = 50;
|
|
558
|
-
align = "left";
|
|
559
|
-
} else if (textPosX === "right") {
|
|
560
|
-
startX = width - 50;
|
|
561
|
-
align = "right";
|
|
562
|
-
}
|
|
563
|
-
ctx.textAlign = align;
|
|
564
|
-
ctx.textBaseline = "alphabetic";
|
|
565
|
-
const fontStr = `${fontStyle} ${fontWeight} ${fontSize}px "${fontFamily}"`;
|
|
566
|
-
ctx.font = fontStr;
|
|
567
|
-
if (letterSpacing !== 0) {
|
|
568
|
-
ctx.letterSpacing = `${letterSpacing}px`;
|
|
569
|
-
}
|
|
570
|
-
let startY = (height - textBlockHeight) / 2 + fontSize * 0.85;
|
|
571
|
-
if (textPosY === "top") {
|
|
572
|
-
startY = 40 + fontSize * 0.85;
|
|
573
|
-
} else if (textPosY === "bottom") {
|
|
574
|
-
startY = height - 40 - textBlockHeight + fontSize * 0.85;
|
|
575
|
-
}
|
|
576
|
-
ctx.save();
|
|
577
|
-
if (skewX !== 0) {
|
|
578
|
-
ctx.transform(1, 0, skewX, 1, 0, 0);
|
|
579
|
-
}
|
|
580
|
-
ctx.fillStyle = "#FFFFFF";
|
|
581
|
-
lines.forEach((line, index) => {
|
|
582
|
-
const py = startY + index * fontSize * lineHeight;
|
|
583
|
-
ctx.fillText(line, startX, py);
|
|
584
|
-
});
|
|
585
|
-
ctx.restore();
|
|
586
|
-
const imgData = ctx.getImageData(0, 0, width, height);
|
|
587
|
-
const pixels = imgData.data;
|
|
588
|
-
let minY = height;
|
|
589
|
-
let maxY = 0;
|
|
590
|
-
for (let y = 0; y < height; y++) {
|
|
591
|
-
for (let x = 0; x < width; x++) {
|
|
592
|
-
const idx = (y * width + x) * 4;
|
|
593
|
-
if (pixels[idx + 3] > 128) {
|
|
594
|
-
if (y < minY) minY = y;
|
|
595
|
-
if (y > maxY) maxY = y;
|
|
596
|
-
}
|
|
597
|
-
}
|
|
598
|
-
}
|
|
599
|
-
if (minY >= maxY) return;
|
|
600
|
-
const step = Math.max(1, Math.min(3, 1 / bristleDensity));
|
|
601
|
-
for (let y = minY; y <= maxY; y += step) {
|
|
602
|
-
const segments = [];
|
|
603
|
-
let inSegment = false;
|
|
604
|
-
let xStart = 0;
|
|
605
|
-
const targetY = Math.floor(y);
|
|
606
|
-
for (let x = 0; x < width; x++) {
|
|
607
|
-
const idx = (targetY * width + x) * 4;
|
|
608
|
-
const isInside = pixels[idx + 3] > 128;
|
|
609
|
-
if (isInside && !inSegment) {
|
|
610
|
-
inSegment = true;
|
|
611
|
-
xStart = x;
|
|
612
|
-
} else if (!isInside && inSegment) {
|
|
613
|
-
inSegment = false;
|
|
614
|
-
segments.push({ xStart, xEnd: x - 1 });
|
|
615
|
-
}
|
|
616
|
-
}
|
|
617
|
-
if (inSegment) {
|
|
618
|
-
segments.push({ xStart, xEnd: width - 1 });
|
|
619
|
-
}
|
|
620
|
-
for (const seg of segments) {
|
|
621
|
-
if (rand() < bristleSkipRate) continue;
|
|
622
|
-
const segW = seg.xEnd - seg.xStart;
|
|
623
|
-
const startLimit = seg.xStart + rand() * Math.min(15, segW * 0.2);
|
|
624
|
-
const endLimit = seg.xEnd - rand() * Math.min(15, segW * 0.2);
|
|
625
|
-
if (startLimit >= endLimit) continue;
|
|
626
|
-
const opacity = 0.4 + rand() * 0.6;
|
|
627
|
-
const lw = 0.5 + rand() * 1.5;
|
|
628
|
-
const hasGap = rand() < 0.1;
|
|
629
|
-
if (hasGap) {
|
|
630
|
-
const gapPct = 0.3 + rand() * 0.4;
|
|
631
|
-
const gapLen = 5 + rand() * 15;
|
|
632
|
-
const midX = startLimit + (endLimit - startLimit) * gapPct;
|
|
633
|
-
const p1Start = startLimit;
|
|
634
|
-
const p1End = Math.max(startLimit, midX - gapLen / 2);
|
|
635
|
-
const p2Start = Math.min(endLimit, midX + gapLen / 2);
|
|
636
|
-
const p2End = endLimit;
|
|
637
|
-
if (p1End > p1Start) {
|
|
638
|
-
this.bristleLines.push({ y: targetY, x0: p1Start, x1: p1End, opacity, lineWidth: lw });
|
|
639
|
-
}
|
|
640
|
-
if (p2End > p2Start) {
|
|
641
|
-
this.bristleLines.push({ y: targetY, x0: p2Start, x1: p2End, opacity, lineWidth: lw });
|
|
642
|
-
}
|
|
643
|
-
} else {
|
|
644
|
-
this.bristleLines.push({ y: targetY, x0: startLimit, x1: endLimit, opacity, lineWidth: lw });
|
|
645
|
-
}
|
|
646
|
-
}
|
|
647
|
-
}
|
|
648
|
-
for (let y = minY; y <= maxY; y++) {
|
|
649
|
-
for (let x = 0; x < width; x++) {
|
|
650
|
-
const idx = (y * width + x) * 4;
|
|
651
|
-
if (pixels[idx + 3] > 128) {
|
|
652
|
-
if (rand() < grainDensity) {
|
|
653
|
-
this.grainDots.push({
|
|
654
|
-
x,
|
|
655
|
-
y,
|
|
656
|
-
opacity: 0.2 + rand() * 0.3
|
|
657
|
-
});
|
|
658
|
-
}
|
|
659
|
-
}
|
|
660
|
-
}
|
|
661
|
-
}
|
|
662
|
-
const bottomRowForCol = new Array(width).fill(-1);
|
|
663
|
-
for (let x = 0; x < width; x++) {
|
|
664
|
-
for (let y = height - 1; y >= 0; y--) {
|
|
665
|
-
const idx = (y * width + x) * 4;
|
|
666
|
-
if (pixels[idx + 3] > 128) {
|
|
667
|
-
bottomRowForCol[x] = y;
|
|
668
|
-
break;
|
|
669
|
-
}
|
|
670
|
-
}
|
|
671
|
-
}
|
|
672
|
-
for (let x = 0; x < width; x++) {
|
|
673
|
-
const sY = bottomRowForCol[x];
|
|
674
|
-
if (sY === -1) continue;
|
|
675
|
-
if (rand() < dripRate) {
|
|
676
|
-
const length = 8 + rand() * (dripMaxLength - 8);
|
|
677
|
-
const startWidth = 1 + rand() * 1;
|
|
678
|
-
const endWidth = rand() < 0.5 ? startWidth : 0.5;
|
|
679
|
-
const startOpacity = 0.6 + rand() * 0.3;
|
|
680
|
-
const hasBlob = rand() < 0.6;
|
|
681
|
-
const blobRadius = 1.5 + rand() * 1.5;
|
|
682
|
-
this.drips.push({
|
|
683
|
-
x,
|
|
684
|
-
startY: sY,
|
|
685
|
-
length,
|
|
686
|
-
startWidth,
|
|
687
|
-
endWidth,
|
|
688
|
-
startOpacity,
|
|
689
|
-
hasBlob,
|
|
690
|
-
blobRadius
|
|
691
|
-
});
|
|
692
|
-
}
|
|
693
|
-
}
|
|
694
|
-
}
|
|
695
|
-
advanceSteps(steps) {
|
|
696
|
-
}
|
|
697
|
-
drawFrame(ctx) {
|
|
698
|
-
const { text, fontFamily, fontWeight, fontStyle, fontSize, letterSpacing, lineHeight, canvasWidth, canvasHeight, textPosX, textPosY, skewX, inkColor } = this.cfg;
|
|
699
|
-
const width = canvasWidth;
|
|
700
|
-
const height = canvasHeight;
|
|
701
|
-
ctx.clearRect(0, 0, width, height);
|
|
702
|
-
ctx.imageSmoothingEnabled = true;
|
|
703
|
-
const lines = text.split("\n");
|
|
704
|
-
const numLines = lines.length;
|
|
705
|
-
const textBlockHeight = fontSize + (numLines - 1) * fontSize * lineHeight;
|
|
706
|
-
let startX = width / 2;
|
|
707
|
-
let align = "center";
|
|
708
|
-
if (textPosX === "left") {
|
|
709
|
-
startX = 50;
|
|
710
|
-
align = "left";
|
|
711
|
-
} else if (textPosX === "right") {
|
|
712
|
-
startX = width - 50;
|
|
713
|
-
align = "right";
|
|
714
|
-
}
|
|
715
|
-
ctx.textAlign = align;
|
|
716
|
-
ctx.textBaseline = "alphabetic";
|
|
717
|
-
const fontStr = `${fontStyle} ${fontWeight} ${fontSize}px "${fontFamily}"`;
|
|
718
|
-
ctx.font = fontStr;
|
|
719
|
-
if (letterSpacing !== 0) {
|
|
720
|
-
ctx.letterSpacing = `${letterSpacing}px`;
|
|
721
|
-
}
|
|
722
|
-
let startY = (height - textBlockHeight) / 2 + fontSize * 0.85;
|
|
723
|
-
if (textPosY === "top") {
|
|
724
|
-
startY = 40 + fontSize * 0.85;
|
|
725
|
-
} else if (textPosY === "bottom") {
|
|
726
|
-
startY = height - 40 - textBlockHeight + fontSize * 0.85;
|
|
727
|
-
}
|
|
728
|
-
ctx.save();
|
|
729
|
-
if (skewX !== 0) {
|
|
730
|
-
ctx.transform(1, 0, skewX, 1, 0, 0);
|
|
731
|
-
}
|
|
732
|
-
ctx.fillStyle = inkColor;
|
|
733
|
-
lines.forEach((line, index) => {
|
|
734
|
-
const py = startY + index * fontSize * lineHeight;
|
|
735
|
-
ctx.fillText(line, startX, py);
|
|
736
|
-
});
|
|
737
|
-
ctx.restore();
|
|
738
|
-
ctx.save();
|
|
739
|
-
ctx.globalCompositeOperation = "source-in";
|
|
740
|
-
ctx.strokeStyle = inkColor;
|
|
741
|
-
this.bristleLines.forEach((line) => {
|
|
742
|
-
ctx.globalAlpha = line.opacity;
|
|
743
|
-
ctx.lineWidth = line.lineWidth;
|
|
744
|
-
ctx.beginPath();
|
|
745
|
-
ctx.moveTo(line.x0, line.y);
|
|
746
|
-
ctx.lineTo(line.x1, line.y);
|
|
747
|
-
ctx.stroke();
|
|
748
|
-
});
|
|
749
|
-
ctx.fillStyle = inkColor;
|
|
750
|
-
this.grainDots.forEach((dot) => {
|
|
751
|
-
ctx.globalAlpha = dot.opacity;
|
|
752
|
-
ctx.fillRect(dot.x, dot.y, 1, 1);
|
|
753
|
-
});
|
|
754
|
-
ctx.restore();
|
|
755
|
-
const inkRgb = hexToRgb(inkColor);
|
|
756
|
-
ctx.save();
|
|
757
|
-
this.drips.forEach((drip) => {
|
|
758
|
-
const grad = ctx.createLinearGradient(drip.x, drip.startY, drip.x, drip.startY + drip.length);
|
|
759
|
-
grad.addColorStop(0, `rgba(${inkRgb.r}, ${inkRgb.g}, ${inkRgb.b}, ${drip.startOpacity})`);
|
|
760
|
-
grad.addColorStop(1, `rgba(${inkRgb.r}, ${inkRgb.g}, ${inkRgb.b}, 0)`);
|
|
761
|
-
ctx.strokeStyle = grad;
|
|
762
|
-
ctx.lineWidth = drip.startWidth;
|
|
763
|
-
ctx.beginPath();
|
|
764
|
-
ctx.moveTo(drip.x, drip.startY);
|
|
765
|
-
ctx.lineTo(drip.x, drip.startY + drip.length);
|
|
766
|
-
ctx.stroke();
|
|
767
|
-
if (drip.hasBlob) {
|
|
768
|
-
ctx.fillStyle = `rgba(${inkRgb.r}, ${inkRgb.g}, ${inkRgb.b}, ${drip.startOpacity * 0.5})`;
|
|
769
|
-
ctx.beginPath();
|
|
770
|
-
ctx.arc(drip.x, drip.startY + drip.length, drip.blobRadius, 0, Math.PI * 2);
|
|
771
|
-
ctx.fill();
|
|
772
|
-
}
|
|
773
|
-
});
|
|
774
|
-
ctx.restore();
|
|
775
|
-
}
|
|
776
|
-
};
|
|
777
|
-
|
|
778
397
|
// src/canvas-utils.ts
|
|
779
398
|
function drawRoundedRect(ctx, x, y, w, h, r) {
|
|
780
399
|
const radius = Math.max(0, Math.min(r, Math.min(w, h) / 2));
|
|
@@ -804,8 +423,20 @@ function restoreLetterSpacing(ctx, saved) {
|
|
|
804
423
|
ctx.letterSpacing = saved;
|
|
805
424
|
}
|
|
806
425
|
|
|
426
|
+
// src/engine/procedural/utils.ts
|
|
427
|
+
function hexToRgb(hex) {
|
|
428
|
+
const shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
|
|
429
|
+
const fullHex = hex.replace(shorthandRegex, (m, r, g, b) => r + r + g + g + b + b);
|
|
430
|
+
const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(fullHex);
|
|
431
|
+
return result ? {
|
|
432
|
+
r: parseInt(result[1], 16),
|
|
433
|
+
g: parseInt(result[2], 16),
|
|
434
|
+
b: parseInt(result[3], 16)
|
|
435
|
+
} : { r: 255, g: 255, b: 255 };
|
|
436
|
+
}
|
|
437
|
+
|
|
807
438
|
// src/renderer.ts
|
|
808
|
-
function
|
|
439
|
+
function getCanvas2DContext(canvas) {
|
|
809
440
|
return canvas.getContext("2d");
|
|
810
441
|
}
|
|
811
442
|
function ctxSupportsFilter(ctx) {
|
|
@@ -820,11 +451,6 @@ function ctxSupportsFilter(ctx) {
|
|
|
820
451
|
}
|
|
821
452
|
}
|
|
822
453
|
function renderTextEffectCore(ctx, cfg) {
|
|
823
|
-
if (cfg.customRenderer === "InkBrushEngine") {
|
|
824
|
-
const engine = new InkBrushEngine(cfg);
|
|
825
|
-
engine.drawFrame(ctx);
|
|
826
|
-
return;
|
|
827
|
-
}
|
|
828
454
|
const { text, fontFamily, fontWeight, fontStyle, fontSize, letterSpacing, lineHeight, fillType, fillColor, fillGradientAngle, fillGradientStops, patternType, strokeEnabled, strokeColor, strokeWidth, strokePosition, strokeOpacity, strokeLineJoin, strokeBlur, strokeType, strokeColorSecondary, strokeWidthSecondary, strokeFadeRange, glowLayers, shadowEnabled, shadowColor, shadowBlur, shadowOffsetX, shadowOffsetY, shadowOpacity, shadowType, bevelEnabled, bevelDepth, bevelHighlight, bevelShadow, bevelDirection, bevelCoreColor, bevelEdgeColor, bevelEdgeWidth, bevelBlur, bevelBlurColor, bevelPerspectiveEnabled, bevelVanishingPointX, bevelVanishingPointY, bevelFocalLength, stackEnabled, stackCount, stackOffsetX, stackOffsetY, stackOpacityDecay, stackColor1, stackColor2, stackColor3, stackColor4, panelEnabled, panelColor, panelOpacity, panelRadius, panelPaddingX, panelPaddingY, panelStrokeEnabled, panelStrokeColor, panelStrokeWidth, canvasWidth, canvasHeight, textPosX, textPosY } = cfg;
|
|
829
455
|
ctx.imageSmoothingEnabled = true;
|
|
830
456
|
ctx.lineJoin = strokeLineJoin;
|
|
@@ -1010,6 +636,68 @@ function renderTextEffectCore(ctx, cfg) {
|
|
|
1010
636
|
}
|
|
1011
637
|
ctx.restore();
|
|
1012
638
|
};
|
|
639
|
+
const renderGlowLayer = (layer2) => {
|
|
640
|
+
let glowCanvas = null;
|
|
641
|
+
try {
|
|
642
|
+
glowCanvas = createCanvas(Math.max(1, Math.ceil(cWidth)), Math.max(1, Math.ceil(cHeight)));
|
|
643
|
+
const glowCtx = getCanvas2DContext(glowCanvas);
|
|
644
|
+
if (!glowCtx) return false;
|
|
645
|
+
glowCtx.clearRect(0, 0, cWidth, cHeight);
|
|
646
|
+
glowCtx.save();
|
|
647
|
+
glowCtx.font = fontStr;
|
|
648
|
+
glowCtx.textAlign = align;
|
|
649
|
+
glowCtx.textBaseline = "alphabetic";
|
|
650
|
+
if (letterSpacing !== 0) glowCtx.letterSpacing = `${letterSpacing}px`;
|
|
651
|
+
glowCtx.globalAlpha = Math.max(0, Math.min(100, layer2.opacity)) / 100;
|
|
652
|
+
glowCtx.fillStyle = layer2.color;
|
|
653
|
+
glowCtx.strokeStyle = layer2.color;
|
|
654
|
+
const spread = Math.max(0, layer2.spread ?? 0);
|
|
655
|
+
if (spread > 0) {
|
|
656
|
+
glowCtx.lineWidth = spread * 2;
|
|
657
|
+
glowCtx.lineJoin = strokeLineJoin;
|
|
658
|
+
}
|
|
659
|
+
const drawSource = () => {
|
|
660
|
+
lines.forEach((line, index) => {
|
|
661
|
+
const py = startY + index * lineAdvance;
|
|
662
|
+
if (spread > 0) glowCtx.strokeText(line, startX, py);
|
|
663
|
+
glowCtx.fillText(line, startX, py);
|
|
664
|
+
});
|
|
665
|
+
};
|
|
666
|
+
const useFilter = ctxSupportsFilter(glowCtx);
|
|
667
|
+
if (useFilter) {
|
|
668
|
+
glowCtx.filter = `blur(${Math.max(0, layer2.blur)}px)`;
|
|
669
|
+
drawSource();
|
|
670
|
+
glowCtx.filter = "none";
|
|
671
|
+
} else {
|
|
672
|
+
glowCtx.shadowColor = layer2.color;
|
|
673
|
+
glowCtx.shadowBlur = Math.max(0, layer2.blur);
|
|
674
|
+
glowCtx.shadowOffsetX = 0;
|
|
675
|
+
glowCtx.shadowOffsetY = 0;
|
|
676
|
+
drawSource();
|
|
677
|
+
glowCtx.shadowColor = "transparent";
|
|
678
|
+
glowCtx.shadowBlur = 0;
|
|
679
|
+
}
|
|
680
|
+
glowCtx.globalCompositeOperation = "destination-out";
|
|
681
|
+
glowCtx.globalAlpha = 1;
|
|
682
|
+
drawSource();
|
|
683
|
+
glowCtx.restore();
|
|
684
|
+
ctx.save();
|
|
685
|
+
if (layer2.type === "inner") {
|
|
686
|
+
ctx.globalCompositeOperation = "source-atop";
|
|
687
|
+
}
|
|
688
|
+
ctx.globalAlpha = 1;
|
|
689
|
+
const passes = Math.max(1, Math.min(20, layer2.strength ?? 1));
|
|
690
|
+
for (let pass = 0; pass < passes; pass += 1) {
|
|
691
|
+
ctx.drawImage(glowCanvas, 0, 0);
|
|
692
|
+
}
|
|
693
|
+
ctx.restore();
|
|
694
|
+
return true;
|
|
695
|
+
} catch {
|
|
696
|
+
return false;
|
|
697
|
+
} finally {
|
|
698
|
+
if (glowCanvas) releaseCanvas(glowCanvas);
|
|
699
|
+
}
|
|
700
|
+
};
|
|
1013
701
|
if (panelEnabled) {
|
|
1014
702
|
ctx.save();
|
|
1015
703
|
ctx.globalAlpha = panelOpacity / 100;
|
|
@@ -1059,9 +747,11 @@ function renderTextEffectCore(ctx, cfg) {
|
|
|
1059
747
|
}
|
|
1060
748
|
glowLayers.forEach((layer2) => {
|
|
1061
749
|
if (layer2.enabled && layer2.type === "outer" && layer2.opacity > 0) {
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
750
|
+
if (!renderGlowLayer(layer2)) {
|
|
751
|
+
const renderCount = Math.max(1, Math.min(20, layer2.strength ?? 1));
|
|
752
|
+
for (let i = 0; i < renderCount; i += 1) {
|
|
753
|
+
renderWithShadowTrick("fill", layer2.color, layer2.blur, 0, 0, layer2.opacity, "#000", layer2.spread ?? 0);
|
|
754
|
+
}
|
|
1065
755
|
}
|
|
1066
756
|
}
|
|
1067
757
|
});
|
|
@@ -1419,7 +1109,7 @@ function renderTextEffectCore(ctx, cfg) {
|
|
|
1419
1109
|
patCanvas.width = 120;
|
|
1420
1110
|
patCanvas.height = 120;
|
|
1421
1111
|
}
|
|
1422
|
-
const patCtx =
|
|
1112
|
+
const patCtx = getCanvas2DContext(patCanvas);
|
|
1423
1113
|
const seedRandom = (initSeed) => {
|
|
1424
1114
|
let currentSeed = initSeed;
|
|
1425
1115
|
return () => {
|
|
@@ -1833,7 +1523,7 @@ function renderTextEffectCore(ctx, cfg) {
|
|
|
1833
1523
|
const tCanvas = createCanvas(cWidth, cHeight);
|
|
1834
1524
|
tCanvas.width = cWidth;
|
|
1835
1525
|
tCanvas.height = cHeight;
|
|
1836
|
-
const tCtx =
|
|
1526
|
+
const tCtx = getCanvas2DContext(tCanvas);
|
|
1837
1527
|
if (tCtx) {
|
|
1838
1528
|
tCtx.font = fontStr;
|
|
1839
1529
|
tCtx.textAlign = align;
|
|
@@ -1962,7 +1652,7 @@ function renderTextEffectCore(ctx, cfg) {
|
|
|
1962
1652
|
const tintCanvas = createCanvas(cWidth, cHeight);
|
|
1963
1653
|
tintCanvas.width = cWidth;
|
|
1964
1654
|
tintCanvas.height = cHeight;
|
|
1965
|
-
const tintCtx =
|
|
1655
|
+
const tintCtx = getCanvas2DContext(tintCanvas);
|
|
1966
1656
|
if (tintCtx) {
|
|
1967
1657
|
tintCtx.drawImage(tCanvas, 0, 0);
|
|
1968
1658
|
tintCtx.globalCompositeOperation = "source-in";
|
|
@@ -1989,10 +1679,12 @@ function renderTextEffectCore(ctx, cfg) {
|
|
|
1989
1679
|
glowLayers.forEach((layer2) => {
|
|
1990
1680
|
if (layer2.enabled && layer2.type === "inner" && layer2.opacity > 0) {
|
|
1991
1681
|
ctx.save();
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1682
|
+
if (!renderGlowLayer(layer2)) {
|
|
1683
|
+
ctx.globalCompositeOperation = "source-atop";
|
|
1684
|
+
const renderCount = Math.max(1, Math.min(20, layer2.strength ?? 1));
|
|
1685
|
+
for (let i = 0; i < renderCount; i += 1) {
|
|
1686
|
+
renderWithShadowTrick("fill", layer2.color, layer2.blur, 0, 0, layer2.opacity, "#000000", layer2.spread ?? 0);
|
|
1687
|
+
}
|
|
1996
1688
|
}
|
|
1997
1689
|
ctx.restore();
|
|
1998
1690
|
}
|
|
@@ -2095,245 +1787,27 @@ var defaultConfig = {
|
|
|
2095
1787
|
textPosX: "center",
|
|
2096
1788
|
textPosY: "middle",
|
|
2097
1789
|
wrapText: true,
|
|
2098
|
-
autoFitText: false
|
|
2099
|
-
// Ink Brush custom properties
|
|
2100
|
-
inkColor: "#FFFFFF",
|
|
2101
|
-
bristleDensity: 0.8,
|
|
2102
|
-
bristleSkipRate: 0.2,
|
|
2103
|
-
dripRate: 0.3,
|
|
2104
|
-
dripMaxLength: 40,
|
|
2105
|
-
grainDensity: 0.15,
|
|
2106
|
-
skewX: -0.2
|
|
1790
|
+
autoFitText: false
|
|
2107
1791
|
};
|
|
2108
|
-
|
|
2109
|
-
{
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
{ color: "#E05300", offset: 100 }
|
|
2128
|
-
],
|
|
2129
|
-
strokeEnabled: true,
|
|
2130
|
-
strokeColor: "#FFFFFF",
|
|
2131
|
-
strokeWidth: 15,
|
|
2132
|
-
strokePosition: "outside",
|
|
2133
|
-
strokeType: "single",
|
|
2134
|
-
strokeLineJoin: "round",
|
|
2135
|
-
strokeOpacity: 100,
|
|
2136
|
-
bevelEnabled: true,
|
|
2137
|
-
bevelDepth: 8,
|
|
2138
|
-
bevelDirection: "bottom-right",
|
|
2139
|
-
bevelHighlight: "#FFCE00",
|
|
2140
|
-
bevelCoreColor: "#4E1901",
|
|
2141
|
-
bevelShadow: "#1D0A00",
|
|
2142
|
-
shadowEnabled: true,
|
|
2143
|
-
shadowColor: "#000000",
|
|
2144
|
-
shadowBlur: 14,
|
|
2145
|
-
shadowOffsetX: 6,
|
|
2146
|
-
shadowOffsetY: 8,
|
|
2147
|
-
shadowOpacity: 65,
|
|
2148
|
-
shadowType: "drop"
|
|
2149
|
-
}
|
|
2150
|
-
},
|
|
2151
|
-
{
|
|
2152
|
-
id: "premium-holo",
|
|
2153
|
-
name: "HOLOGRAPHIC",
|
|
2154
|
-
category: "Classic",
|
|
2155
|
-
config: {
|
|
2156
|
-
...defaultConfig,
|
|
2157
|
-
text: "TEXT",
|
|
2158
|
-
effectName: "HolographicEffect",
|
|
2159
|
-
fontFamily: "Impact",
|
|
2160
|
-
fontWeight: 900,
|
|
2161
|
-
fontStyle: "normal",
|
|
2162
|
-
fontSize: 100,
|
|
2163
|
-
letterSpacing: 2,
|
|
2164
|
-
lineHeight: 1.2,
|
|
2165
|
-
fillType: "linear",
|
|
2166
|
-
fillGradientAngle: 125,
|
|
2167
|
-
fillGradientStops: [
|
|
2168
|
-
{ color: "#6FE3FF", offset: 0 },
|
|
2169
|
-
{ color: "#D196FF", offset: 25 },
|
|
2170
|
-
{ color: "#FF9CEE", offset: 50 },
|
|
2171
|
-
{ color: "#FFE49E", offset: 75 },
|
|
2172
|
-
{ color: "#D4FFF1", offset: 100 }
|
|
2173
|
-
],
|
|
2174
|
-
strokeEnabled: true,
|
|
2175
|
-
strokeColor: "#FFFFFF",
|
|
2176
|
-
strokeWidth: 2,
|
|
2177
|
-
strokePosition: "outside",
|
|
2178
|
-
strokeType: "single",
|
|
2179
|
-
strokeOpacity: 100,
|
|
2180
|
-
glowLayers: [{ enabled: true, color: "#D196FF", blur: 15, opacity: 50, type: "outer" }],
|
|
2181
|
-
bevelEnabled: true,
|
|
2182
|
-
bevelDepth: 4,
|
|
2183
|
-
bevelDirection: "bottom-right",
|
|
2184
|
-
bevelHighlight: "#FFFFFF",
|
|
2185
|
-
bevelCoreColor: "#2A3540",
|
|
2186
|
-
bevelShadow: "#0E151D",
|
|
2187
|
-
shadowEnabled: true,
|
|
2188
|
-
shadowColor: "#000000",
|
|
2189
|
-
shadowBlur: 20,
|
|
2190
|
-
shadowOffsetX: 6,
|
|
2191
|
-
shadowOffsetY: 10,
|
|
2192
|
-
shadowOpacity: 90,
|
|
2193
|
-
shadowType: "drop"
|
|
2194
|
-
}
|
|
2195
|
-
},
|
|
2196
|
-
{
|
|
2197
|
-
id: "classic-ink",
|
|
2198
|
-
name: "Classic Ink",
|
|
2199
|
-
category: "Classic",
|
|
2200
|
-
config: {
|
|
2201
|
-
...defaultConfig,
|
|
2202
|
-
text: "Classic Ink",
|
|
2203
|
-
effectName: "ClassicInk",
|
|
2204
|
-
fontFamily: "Playfair Display",
|
|
2205
|
-
fontWeight: 700,
|
|
2206
|
-
fontStyle: "normal",
|
|
2207
|
-
fontSize: 85,
|
|
2208
|
-
letterSpacing: 1,
|
|
2209
|
-
lineHeight: 1.2,
|
|
2210
|
-
fillType: "linear",
|
|
2211
|
-
fillGradientAngle: 90,
|
|
2212
|
-
fillGradientStops: [
|
|
2213
|
-
{ color: "#FDFBF7", offset: 0 },
|
|
2214
|
-
{ color: "#EAE5D9", offset: 100 }
|
|
2215
|
-
],
|
|
2216
|
-
strokeEnabled: true,
|
|
2217
|
-
strokeColor: "#1E1E26",
|
|
2218
|
-
strokeWidth: 2,
|
|
2219
|
-
strokePosition: "outside",
|
|
2220
|
-
strokeOpacity: 100,
|
|
2221
|
-
strokeLineJoin: "round",
|
|
2222
|
-
shadowEnabled: true,
|
|
2223
|
-
shadowColor: "#3D2B1F",
|
|
2224
|
-
shadowBlur: 14,
|
|
2225
|
-
shadowOffsetX: 6,
|
|
2226
|
-
shadowOffsetY: 6,
|
|
2227
|
-
shadowOpacity: 90,
|
|
2228
|
-
shadowType: "drop"
|
|
2229
|
-
}
|
|
2230
|
-
},
|
|
2231
|
-
{
|
|
2232
|
-
id: "neon-crimson",
|
|
2233
|
-
name: "Neon Crimson",
|
|
2234
|
-
category: "Neon",
|
|
2235
|
-
config: {
|
|
2236
|
-
...defaultConfig,
|
|
2237
|
-
text: "NEON",
|
|
2238
|
-
effectName: "NeonCrimson",
|
|
2239
|
-
fontFamily: "Bebas Neue",
|
|
2240
|
-
fontWeight: 700,
|
|
2241
|
-
fontStyle: "normal",
|
|
2242
|
-
fontSize: 100,
|
|
2243
|
-
letterSpacing: 6,
|
|
2244
|
-
lineHeight: 1.2,
|
|
2245
|
-
fillType: "none",
|
|
2246
|
-
strokeEnabled: true,
|
|
2247
|
-
strokeColor: "#FFFFFF",
|
|
2248
|
-
strokeWidth: 3,
|
|
2249
|
-
strokePosition: "center",
|
|
2250
|
-
strokeOpacity: 100,
|
|
2251
|
-
strokeLineJoin: "round",
|
|
2252
|
-
glowLayers: [
|
|
2253
|
-
{ enabled: true, color: "#FF003C", blur: 12, opacity: 100, type: "outer" },
|
|
2254
|
-
{ enabled: true, color: "#FF003C", blur: 35, opacity: 80, type: "outer" },
|
|
2255
|
-
{ enabled: true, color: "#FF003C", blur: 80, opacity: 60, type: "outer" }
|
|
2256
|
-
],
|
|
2257
|
-
shadowEnabled: false
|
|
2258
|
-
}
|
|
2259
|
-
},
|
|
2260
|
-
{
|
|
2261
|
-
id: "cyberpunk-yellow",
|
|
2262
|
-
name: "Cyberpunk Yellow",
|
|
2263
|
-
category: "Neon",
|
|
2264
|
-
config: {
|
|
2265
|
-
...defaultConfig,
|
|
2266
|
-
text: "CYBER",
|
|
2267
|
-
effectName: "CyberpunkYellow",
|
|
2268
|
-
fontFamily: "Anton",
|
|
2269
|
-
fontWeight: 900,
|
|
2270
|
-
fontStyle: "normal",
|
|
2271
|
-
fontSize: 90,
|
|
2272
|
-
letterSpacing: 2,
|
|
2273
|
-
lineHeight: 1.2,
|
|
2274
|
-
fillType: "solid",
|
|
2275
|
-
fillColor: "#FFE600",
|
|
2276
|
-
strokeEnabled: true,
|
|
2277
|
-
strokeColor: "#000000",
|
|
2278
|
-
strokeWidth: 6,
|
|
2279
|
-
strokePosition: "outside",
|
|
2280
|
-
strokeOpacity: 100,
|
|
2281
|
-
strokeLineJoin: "round",
|
|
2282
|
-
shadowEnabled: true,
|
|
2283
|
-
shadowColor: "#FFE600",
|
|
2284
|
-
shadowBlur: 15,
|
|
2285
|
-
shadowOffsetX: 4,
|
|
2286
|
-
shadowOffsetY: 4,
|
|
2287
|
-
shadowOpacity: 95,
|
|
2288
|
-
shadowType: "drop"
|
|
2289
|
-
}
|
|
2290
|
-
},
|
|
2291
|
-
{
|
|
2292
|
-
id: "retro-comic",
|
|
2293
|
-
name: "Retro Comic",
|
|
2294
|
-
category: "Experimental",
|
|
2295
|
-
config: {
|
|
2296
|
-
...defaultConfig,
|
|
2297
|
-
text: "BOOM!",
|
|
2298
|
-
effectName: "RetroComic",
|
|
2299
|
-
fontFamily: "Arial Black",
|
|
2300
|
-
fontWeight: 900,
|
|
2301
|
-
fontStyle: "normal",
|
|
2302
|
-
fontSize: 85,
|
|
2303
|
-
letterSpacing: 3,
|
|
2304
|
-
lineHeight: 1.1,
|
|
2305
|
-
fillType: "solid",
|
|
2306
|
-
fillColor: "#000000",
|
|
2307
|
-
strokeEnabled: true,
|
|
2308
|
-
strokeColor: "#FFFFFF",
|
|
2309
|
-
strokeWidth: 6,
|
|
2310
|
-
strokePosition: "outside",
|
|
2311
|
-
strokeOpacity: 100,
|
|
2312
|
-
strokeLineJoin: "round",
|
|
2313
|
-
glowLayers: [
|
|
2314
|
-
{ enabled: true, color: "#000000", blur: 0, opacity: 100, type: "outer", strength: 1, spread: 3 },
|
|
2315
|
-
{ enabled: false, color: "#FF007C", blur: 40, opacity: 60, type: "outer" },
|
|
2316
|
-
{ enabled: false, color: "#00F0FF", blur: 60, opacity: 40, type: "outer" }
|
|
2317
|
-
],
|
|
2318
|
-
// panelEnabled: true,
|
|
2319
|
-
// panelColor: "#FFE100",
|
|
2320
|
-
// panelOpacity: 100,
|
|
2321
|
-
// panelRadius: 10,
|
|
2322
|
-
// panelPaddingX: 55,
|
|
2323
|
-
// panelPaddingY: 35,
|
|
2324
|
-
// panelStrokeEnabled: true,
|
|
2325
|
-
// panelStrokeColor: "#000000",
|
|
2326
|
-
// panelStrokeWidth: 4,
|
|
2327
|
-
shadowEnabled: true,
|
|
2328
|
-
shadowColor: "#000000",
|
|
2329
|
-
shadowBlur: 0,
|
|
2330
|
-
shadowOffsetX: 8,
|
|
2331
|
-
shadowOffsetY: 8,
|
|
2332
|
-
shadowOpacity: 100,
|
|
2333
|
-
shadowType: "drop"
|
|
2334
|
-
}
|
|
2335
|
-
}
|
|
2336
|
-
];
|
|
1792
|
+
function createBlankTextEffectConfig() {
|
|
1793
|
+
return {
|
|
1794
|
+
...defaultConfig,
|
|
1795
|
+
text: "MY TEXT",
|
|
1796
|
+
effectName: "Custom Effect",
|
|
1797
|
+
strokeEnabled: false,
|
|
1798
|
+
shadowEnabled: false,
|
|
1799
|
+
bevelEnabled: false,
|
|
1800
|
+
stackEnabled: false,
|
|
1801
|
+
panelEnabled: false,
|
|
1802
|
+
panelStrokeEnabled: false,
|
|
1803
|
+
perCharFillEnabled: false,
|
|
1804
|
+
glowLayers: defaultConfig.glowLayers.map((layer2) => ({
|
|
1805
|
+
...layer2,
|
|
1806
|
+
enabled: false
|
|
1807
|
+
}))
|
|
1808
|
+
};
|
|
1809
|
+
}
|
|
1810
|
+
var builtInPresets = [];
|
|
2337
1811
|
|
|
2338
1812
|
// src/engine/timelineDefaults.ts
|
|
2339
1813
|
function ensureDefaultTimeline(doc) {
|
|
@@ -2395,7 +1869,7 @@ function cloneSceneWithNewIds(doc) {
|
|
|
2395
1869
|
// src/engine/migrate.ts
|
|
2396
1870
|
function layer(type, name, params, extra) {
|
|
2397
1871
|
return {
|
|
2398
|
-
id: newLayerId(),
|
|
1872
|
+
id: extra?.id ?? newLayerId(),
|
|
2399
1873
|
type,
|
|
2400
1874
|
name,
|
|
2401
1875
|
enabled: true,
|
|
@@ -2406,72 +1880,61 @@ function layer(type, name, params, extra) {
|
|
|
2406
1880
|
...extra
|
|
2407
1881
|
};
|
|
2408
1882
|
}
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
1883
|
+
var REMOVED_INK_FIELDS = [
|
|
1884
|
+
"customRenderer",
|
|
1885
|
+
"inkColor",
|
|
1886
|
+
"bristleDensity",
|
|
1887
|
+
"bristleSkipRate",
|
|
1888
|
+
"dripRate",
|
|
1889
|
+
"dripMaxLength",
|
|
1890
|
+
"grainDensity",
|
|
1891
|
+
"skewX"
|
|
1892
|
+
];
|
|
1893
|
+
function stripRemovedRendererFields(value) {
|
|
1894
|
+
const out = { ...value };
|
|
1895
|
+
for (const key of REMOVED_INK_FIELDS) delete out[key];
|
|
1896
|
+
return out;
|
|
2412
1897
|
}
|
|
2413
1898
|
function textEffectConfigToScene(cfg) {
|
|
2414
|
-
const
|
|
1899
|
+
const safeConfig = stripRemovedRendererFields(cfg);
|
|
2415
1900
|
const layers = [];
|
|
2416
|
-
if (engineId) {
|
|
2417
|
-
layers.push(
|
|
2418
|
-
layer(
|
|
2419
|
-
"customEngine",
|
|
2420
|
-
"Custom Engine",
|
|
2421
|
-
{ engineId },
|
|
2422
|
-
{
|
|
2423
|
-
enabled: true,
|
|
2424
|
-
target: "scene"
|
|
2425
|
-
}
|
|
2426
|
-
)
|
|
2427
|
-
);
|
|
2428
|
-
layers.push(
|
|
2429
|
-
layer(
|
|
2430
|
-
"customEngine",
|
|
2431
|
-
"Engine Params",
|
|
2432
|
-
{ ...collectEngineParams(cfg, engineId) },
|
|
2433
|
-
{
|
|
2434
|
-
enabled: true,
|
|
2435
|
-
target: "text"
|
|
2436
|
-
}
|
|
2437
|
-
)
|
|
2438
|
-
);
|
|
2439
|
-
}
|
|
2440
1901
|
layers.push(
|
|
2441
1902
|
layer(
|
|
2442
1903
|
"panel",
|
|
2443
1904
|
"Background Panel",
|
|
2444
1905
|
{
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
1906
|
+
enabled: safeConfig.panelEnabled,
|
|
1907
|
+
panelEnabled: safeConfig.panelEnabled,
|
|
1908
|
+
panelColor: safeConfig.panelColor,
|
|
1909
|
+
panelOpacity: safeConfig.panelOpacity,
|
|
1910
|
+
panelRadius: safeConfig.panelRadius,
|
|
1911
|
+
panelPaddingX: safeConfig.panelPaddingX,
|
|
1912
|
+
panelPaddingY: safeConfig.panelPaddingY,
|
|
1913
|
+
panelStrokeEnabled: safeConfig.panelStrokeEnabled,
|
|
1914
|
+
panelStrokeColor: safeConfig.panelStrokeColor,
|
|
1915
|
+
panelStrokeWidth: safeConfig.panelStrokeWidth
|
|
2454
1916
|
},
|
|
2455
|
-
{ enabled:
|
|
1917
|
+
{ enabled: safeConfig.panelEnabled, id: "panel" }
|
|
2456
1918
|
)
|
|
2457
1919
|
);
|
|
2458
|
-
(
|
|
2459
|
-
layers.push(layer("glow", `Glow ${i + 1}`, { ...g }, { enabled: g.enabled, opacity: (g.opacity ?? 100) / 100 }));
|
|
1920
|
+
(safeConfig.glowLayers || []).forEach((g, i) => {
|
|
1921
|
+
layers.push(layer("glow", `Glow ${i + 1}`, { ...g, enabled: g.enabled }, { id: `glow-${i + 1}`, enabled: g.enabled, opacity: (g.opacity ?? 100) / 100 }));
|
|
2460
1922
|
});
|
|
2461
1923
|
layers.push(
|
|
2462
1924
|
layer(
|
|
2463
1925
|
"shadow",
|
|
2464
1926
|
"Shadow",
|
|
2465
1927
|
{
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
1928
|
+
enabled: safeConfig.shadowEnabled,
|
|
1929
|
+
shadowEnabled: safeConfig.shadowEnabled,
|
|
1930
|
+
shadowColor: safeConfig.shadowColor,
|
|
1931
|
+
shadowBlur: safeConfig.shadowBlur,
|
|
1932
|
+
shadowOffsetX: safeConfig.shadowOffsetX,
|
|
1933
|
+
shadowOffsetY: safeConfig.shadowOffsetY,
|
|
1934
|
+
shadowOpacity: safeConfig.shadowOpacity,
|
|
1935
|
+
shadowType: safeConfig.shadowType
|
|
2473
1936
|
},
|
|
2474
|
-
{ enabled:
|
|
1937
|
+
{ enabled: safeConfig.shadowEnabled, id: "shadow" }
|
|
2475
1938
|
)
|
|
2476
1939
|
);
|
|
2477
1940
|
layers.push(
|
|
@@ -2479,22 +1942,23 @@ function textEffectConfigToScene(cfg) {
|
|
|
2479
1942
|
"extrusion",
|
|
2480
1943
|
"Bevel / Extrusion",
|
|
2481
1944
|
{
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
1945
|
+
enabled: safeConfig.bevelEnabled,
|
|
1946
|
+
bevelEnabled: safeConfig.bevelEnabled,
|
|
1947
|
+
bevelDepth: safeConfig.bevelDepth,
|
|
1948
|
+
bevelHighlight: safeConfig.bevelHighlight,
|
|
1949
|
+
bevelShadow: safeConfig.bevelShadow,
|
|
1950
|
+
bevelDirection: safeConfig.bevelDirection,
|
|
1951
|
+
bevelCoreColor: safeConfig.bevelCoreColor,
|
|
1952
|
+
bevelEdgeColor: safeConfig.bevelEdgeColor,
|
|
1953
|
+
bevelEdgeWidth: safeConfig.bevelEdgeWidth,
|
|
1954
|
+
bevelBlur: safeConfig.bevelBlur,
|
|
1955
|
+
bevelBlurColor: safeConfig.bevelBlurColor,
|
|
1956
|
+
bevelPerspectiveEnabled: safeConfig.bevelPerspectiveEnabled,
|
|
1957
|
+
bevelVanishingPointX: safeConfig.bevelVanishingPointX,
|
|
1958
|
+
bevelVanishingPointY: safeConfig.bevelVanishingPointY,
|
|
1959
|
+
bevelFocalLength: safeConfig.bevelFocalLength
|
|
2496
1960
|
},
|
|
2497
|
-
{ enabled:
|
|
1961
|
+
{ enabled: safeConfig.bevelEnabled, id: "extrusion" }
|
|
2498
1962
|
)
|
|
2499
1963
|
);
|
|
2500
1964
|
layers.push(
|
|
@@ -2502,17 +1966,18 @@ function textEffectConfigToScene(cfg) {
|
|
|
2502
1966
|
"duplicateStack",
|
|
2503
1967
|
"Stack Extrusion",
|
|
2504
1968
|
{
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
1969
|
+
enabled: !!safeConfig.stackEnabled,
|
|
1970
|
+
stackEnabled: safeConfig.stackEnabled,
|
|
1971
|
+
stackCount: safeConfig.stackCount,
|
|
1972
|
+
stackOffsetX: safeConfig.stackOffsetX,
|
|
1973
|
+
stackOffsetY: safeConfig.stackOffsetY,
|
|
1974
|
+
stackOpacityDecay: safeConfig.stackOpacityDecay,
|
|
1975
|
+
stackColor1: safeConfig.stackColor1,
|
|
1976
|
+
stackColor2: safeConfig.stackColor2,
|
|
1977
|
+
stackColor3: safeConfig.stackColor3,
|
|
1978
|
+
stackColor4: safeConfig.stackColor4
|
|
2514
1979
|
},
|
|
2515
|
-
{ enabled: !!
|
|
1980
|
+
{ enabled: !!safeConfig.stackEnabled, id: "duplicate-stack" }
|
|
2516
1981
|
)
|
|
2517
1982
|
);
|
|
2518
1983
|
layers.push(
|
|
@@ -2520,19 +1985,20 @@ function textEffectConfigToScene(cfg) {
|
|
|
2520
1985
|
"stroke",
|
|
2521
1986
|
"Stroke",
|
|
2522
1987
|
{
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
|
|
1988
|
+
enabled: safeConfig.strokeEnabled,
|
|
1989
|
+
strokeEnabled: safeConfig.strokeEnabled,
|
|
1990
|
+
strokeColor: safeConfig.strokeColor,
|
|
1991
|
+
strokeWidth: safeConfig.strokeWidth,
|
|
1992
|
+
strokePosition: safeConfig.strokePosition,
|
|
1993
|
+
strokeOpacity: safeConfig.strokeOpacity,
|
|
1994
|
+
strokeLineJoin: safeConfig.strokeLineJoin,
|
|
1995
|
+
strokeBlur: safeConfig.strokeBlur,
|
|
1996
|
+
strokeType: safeConfig.strokeType,
|
|
1997
|
+
strokeColorSecondary: safeConfig.strokeColorSecondary,
|
|
1998
|
+
strokeWidthSecondary: safeConfig.strokeWidthSecondary,
|
|
1999
|
+
strokeFadeRange: safeConfig.strokeFadeRange
|
|
2534
2000
|
},
|
|
2535
|
-
{ enabled:
|
|
2001
|
+
{ enabled: safeConfig.strokeEnabled, id: "stroke" }
|
|
2536
2002
|
)
|
|
2537
2003
|
);
|
|
2538
2004
|
layers.push(
|
|
@@ -2540,73 +2006,57 @@ function textEffectConfigToScene(cfg) {
|
|
|
2540
2006
|
"fill",
|
|
2541
2007
|
"Fill",
|
|
2542
2008
|
{
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
|
|
2548
|
-
|
|
2549
|
-
|
|
2009
|
+
enabled: safeConfig.fillType !== "none",
|
|
2010
|
+
fillType: safeConfig.fillType,
|
|
2011
|
+
fillColor: safeConfig.fillColor,
|
|
2012
|
+
fillGradientAngle: safeConfig.fillGradientAngle,
|
|
2013
|
+
fillGradientStops: safeConfig.fillGradientStops,
|
|
2014
|
+
patternType: safeConfig.patternType,
|
|
2015
|
+
perCharFillEnabled: safeConfig.perCharFillEnabled,
|
|
2016
|
+
charFillColors: safeConfig.charFillColors
|
|
2550
2017
|
},
|
|
2551
|
-
{ enabled:
|
|
2018
|
+
{ enabled: safeConfig.fillType !== "none", id: "fill" }
|
|
2552
2019
|
)
|
|
2553
2020
|
);
|
|
2554
|
-
layers.push(layer("mask", "Text Alpha Mask", { maskType: "alphaText", revealProgress: 1 }, { enabled: false }));
|
|
2555
|
-
layers.push(layer("filter", "Compositor FX", { blur: 0, bloom: 0 }, { enabled: false, target: "previous" }));
|
|
2021
|
+
layers.push(layer("mask", "Text Alpha Mask", { maskType: "alphaText", revealProgress: 1 }, { enabled: false, id: "mask" }));
|
|
2022
|
+
layers.push(layer("filter", "Compositor FX", { blur: 0, bloom: 0 }, { enabled: false, target: "previous", id: "compositor" }));
|
|
2556
2023
|
const doc = {
|
|
2557
2024
|
version: 1,
|
|
2558
|
-
|
|
2025
|
+
schemaVersion: 2,
|
|
2026
|
+
effectName: safeConfig.effectName,
|
|
2559
2027
|
canvas: {
|
|
2560
|
-
width:
|
|
2561
|
-
height:
|
|
2028
|
+
width: safeConfig.canvasWidth,
|
|
2029
|
+
height: safeConfig.canvasHeight,
|
|
2562
2030
|
background: "transparent"
|
|
2563
2031
|
},
|
|
2564
2032
|
text: {
|
|
2565
|
-
content:
|
|
2566
|
-
fontFamily:
|
|
2567
|
-
fontWeight:
|
|
2568
|
-
fontStyle:
|
|
2569
|
-
fontSize:
|
|
2570
|
-
letterSpacing:
|
|
2571
|
-
lineHeight:
|
|
2572
|
-
textPosX:
|
|
2573
|
-
textPosY:
|
|
2574
|
-
wrapText:
|
|
2575
|
-
autoFitText: !!
|
|
2576
|
-
perCharFillEnabled:
|
|
2577
|
-
charFillColors:
|
|
2033
|
+
content: safeConfig.text,
|
|
2034
|
+
fontFamily: safeConfig.fontFamily,
|
|
2035
|
+
fontWeight: safeConfig.fontWeight,
|
|
2036
|
+
fontStyle: safeConfig.fontStyle,
|
|
2037
|
+
fontSize: safeConfig.fontSize,
|
|
2038
|
+
letterSpacing: safeConfig.letterSpacing,
|
|
2039
|
+
lineHeight: safeConfig.lineHeight,
|
|
2040
|
+
textPosX: safeConfig.textPosX,
|
|
2041
|
+
textPosY: safeConfig.textPosY,
|
|
2042
|
+
wrapText: safeConfig.wrapText !== false,
|
|
2043
|
+
autoFitText: !!safeConfig.autoFitText,
|
|
2044
|
+
perCharFillEnabled: safeConfig.perCharFillEnabled,
|
|
2045
|
+
charFillColors: safeConfig.charFillColors
|
|
2578
2046
|
},
|
|
2579
2047
|
effectLayers: layers,
|
|
2580
|
-
customEngineId: engineId,
|
|
2581
|
-
engineParams: engineId ? collectEngineParams(cfg, engineId) : void 0,
|
|
2582
2048
|
compositor: { blur: 0, bloom: 0, bloomThreshold: 0.6 },
|
|
2583
2049
|
timeline: { duration: 2, fps: 30, loop: true, tracks: [] },
|
|
2584
|
-
legacyConfig: { ...
|
|
2050
|
+
legacyConfig: { ...safeConfig }
|
|
2585
2051
|
};
|
|
2586
2052
|
return ensureDefaultTimeline(doc);
|
|
2587
2053
|
}
|
|
2588
|
-
function collectEngineParams(cfg, id) {
|
|
2589
|
-
switch (id) {
|
|
2590
|
-
case "ink":
|
|
2591
|
-
return {
|
|
2592
|
-
inkColor: cfg.inkColor,
|
|
2593
|
-
bristleDensity: cfg.bristleDensity,
|
|
2594
|
-
bristleSkipRate: cfg.bristleSkipRate,
|
|
2595
|
-
dripRate: cfg.dripRate,
|
|
2596
|
-
dripMaxLength: cfg.dripMaxLength,
|
|
2597
|
-
grainDensity: cfg.grainDensity,
|
|
2598
|
-
skewX: cfg.skewX
|
|
2599
|
-
};
|
|
2600
|
-
default:
|
|
2601
|
-
return {};
|
|
2602
|
-
}
|
|
2603
|
-
}
|
|
2604
2054
|
function getLayerParams(doc, type, index = 0) {
|
|
2605
2055
|
const found = doc.effectLayers.filter((l) => l.type === type);
|
|
2606
2056
|
return found[index]?.params;
|
|
2607
2057
|
}
|
|
2608
2058
|
function sceneToConfig(doc) {
|
|
2609
|
-
const base = doc.legacyConfig ?
|
|
2059
|
+
const base = doc.legacyConfig ? stripRemovedRendererFields(doc.legacyConfig) : {
|
|
2610
2060
|
...createDefaultFromScene(doc)
|
|
2611
2061
|
};
|
|
2612
2062
|
base.effectName = doc.effectName;
|
|
@@ -2623,11 +2073,15 @@ function sceneToConfig(doc) {
|
|
|
2623
2073
|
base.autoFitText = !!doc.text.autoFitText;
|
|
2624
2074
|
base.canvasWidth = doc.canvas.width;
|
|
2625
2075
|
base.canvasHeight = doc.canvas.height;
|
|
2076
|
+
const withoutLayerEnabled = (params) => {
|
|
2077
|
+
const { enabled: _enabled, ...visualParams } = params;
|
|
2078
|
+
return visualParams;
|
|
2079
|
+
};
|
|
2626
2080
|
const panel = getLayerParams(doc, "panel");
|
|
2627
2081
|
if (panel) {
|
|
2628
2082
|
Object.assign(base, {
|
|
2629
|
-
panelEnabled: panel.panelEnabled,
|
|
2630
|
-
|
|
2083
|
+
panelEnabled: !!doc.effectLayers.find((l) => l.type === "panel")?.enabled && panel.enabled !== false && panel.panelEnabled !== false,
|
|
2084
|
+
...withoutLayerEnabled(panel),
|
|
2631
2085
|
panelOpacity: panel.panelOpacity,
|
|
2632
2086
|
panelRadius: panel.panelRadius,
|
|
2633
2087
|
panelPaddingX: panel.panelPaddingX,
|
|
@@ -2641,7 +2095,7 @@ function sceneToConfig(doc) {
|
|
|
2641
2095
|
base.glowLayers = glows.map((l) => {
|
|
2642
2096
|
const p = l.params;
|
|
2643
2097
|
return {
|
|
2644
|
-
enabled: l.enabled && (p.enabled ?? true),
|
|
2098
|
+
enabled: l.enabled && (p.enabled ?? true) && (l.opacity ?? 1) > 0,
|
|
2645
2099
|
color: p.color ?? "#7C6FFF",
|
|
2646
2100
|
blur: p.blur ?? 20,
|
|
2647
2101
|
opacity: Math.round((p.opacity ?? 80) * (l.opacity ?? 1)),
|
|
@@ -2660,23 +2114,17 @@ function sceneToConfig(doc) {
|
|
|
2660
2114
|
});
|
|
2661
2115
|
}
|
|
2662
2116
|
const shadow = getLayerParams(doc, "shadow");
|
|
2663
|
-
if (shadow) Object.assign(base, shadow);
|
|
2117
|
+
if (shadow) Object.assign(base, { ...withoutLayerEnabled(shadow), shadowEnabled: !!doc.effectLayers.find((l) => l.type === "shadow")?.enabled && shadow.enabled !== false && shadow.shadowEnabled !== false });
|
|
2664
2118
|
const extrusion = getLayerParams(doc, "extrusion");
|
|
2665
|
-
if (extrusion) Object.assign(base, extrusion);
|
|
2119
|
+
if (extrusion) Object.assign(base, { ...withoutLayerEnabled(extrusion), bevelEnabled: !!doc.effectLayers.find((l) => l.type === "extrusion")?.enabled && extrusion.enabled !== false && extrusion.bevelEnabled !== false });
|
|
2666
2120
|
const stack = getLayerParams(doc, "duplicateStack");
|
|
2667
|
-
if (stack) Object.assign(base, stack);
|
|
2121
|
+
if (stack) Object.assign(base, { ...withoutLayerEnabled(stack), stackEnabled: !!doc.effectLayers.find((l) => l.type === "duplicateStack")?.enabled && stack.enabled !== false && stack.stackEnabled !== false });
|
|
2668
2122
|
const stroke = getLayerParams(doc, "stroke");
|
|
2669
|
-
if (stroke) Object.assign(base, stroke);
|
|
2123
|
+
if (stroke) Object.assign(base, { ...withoutLayerEnabled(stroke), strokeEnabled: !!doc.effectLayers.find((l) => l.type === "stroke")?.enabled && stroke.enabled !== false && stroke.strokeEnabled !== false });
|
|
2670
2124
|
const fill = getLayerParams(doc, "fill");
|
|
2671
|
-
if (fill) Object.assign(base, fill);
|
|
2125
|
+
if (fill) Object.assign(base, withoutLayerEnabled(fill));
|
|
2672
2126
|
base.perCharFillEnabled = doc.text.perCharFillEnabled ?? fill?.perCharFillEnabled;
|
|
2673
2127
|
base.charFillColors = doc.text.charFillColors ?? fill?.charFillColors;
|
|
2674
|
-
if (doc.customEngineId) {
|
|
2675
|
-
base.customRenderer = ENGINE_ID_TO_LEGACY[doc.customEngineId];
|
|
2676
|
-
Object.assign(base, doc.engineParams || {});
|
|
2677
|
-
} else {
|
|
2678
|
-
base.customRenderer = void 0;
|
|
2679
|
-
}
|
|
2680
2128
|
base.glowLayers = base.glowLayers.slice(0, 6);
|
|
2681
2129
|
const filterLayers = doc.effectLayers.filter((l) => l.type === "filter" && l.enabled);
|
|
2682
2130
|
const filter = filterLayers[filterLayers.length - 1]?.params;
|
|
@@ -2759,7 +2207,7 @@ function _buildConfig(effect, text, fontSize, canvasWidth, canvasHeight, time, c
|
|
|
2759
2207
|
if (effect.animation) {
|
|
2760
2208
|
config.animation = effect.animation;
|
|
2761
2209
|
}
|
|
2762
|
-
if (fill) {
|
|
2210
|
+
if (fill && fill.enabled !== false) {
|
|
2763
2211
|
if (fill.type !== void 0) config.fillType = fill.type;
|
|
2764
2212
|
if (fill.color !== void 0) config.fillColor = fill.color;
|
|
2765
2213
|
if (fill.gradient?.angle !== void 0) config.fillGradientAngle = fill.gradient.angle;
|
|
@@ -2770,7 +2218,7 @@ function _buildConfig(effect, text, fontSize, canvasWidth, canvasHeight, time, c
|
|
|
2770
2218
|
} else {
|
|
2771
2219
|
config.fillType = "none";
|
|
2772
2220
|
}
|
|
2773
|
-
config.strokeEnabled = !!stroke;
|
|
2221
|
+
config.strokeEnabled = !!stroke && stroke.enabled !== false;
|
|
2774
2222
|
if (stroke) {
|
|
2775
2223
|
if (stroke.color !== void 0) config.strokeColor = stroke.color;
|
|
2776
2224
|
if (stroke.width !== void 0) config.strokeWidth = stroke.width * ratio;
|
|
@@ -2783,7 +2231,7 @@ function _buildConfig(effect, text, fontSize, canvasWidth, canvasHeight, time, c
|
|
|
2783
2231
|
if (stroke.widthSecondary !== void 0) config.strokeWidthSecondary = stroke.widthSecondary * ratio;
|
|
2784
2232
|
if (stroke.fadeRange !== void 0) config.strokeFadeRange = stroke.fadeRange;
|
|
2785
2233
|
}
|
|
2786
|
-
config.shadowEnabled = !!shadow;
|
|
2234
|
+
config.shadowEnabled = !!shadow && shadow.enabled !== false;
|
|
2787
2235
|
if (shadow) {
|
|
2788
2236
|
if (shadow.color !== void 0) config.shadowColor = shadow.color;
|
|
2789
2237
|
if (shadow.blur !== void 0) config.shadowBlur = shadow.blur * ratio;
|
|
@@ -2794,7 +2242,7 @@ function _buildConfig(effect, text, fontSize, canvasWidth, canvasHeight, time, c
|
|
|
2794
2242
|
if (shadow.opacity !== void 0) config.shadowOpacity = shadow.opacity;
|
|
2795
2243
|
if (shadow.type !== void 0) config.shadowType = shadow.type;
|
|
2796
2244
|
}
|
|
2797
|
-
config.bevelEnabled = !!bevel;
|
|
2245
|
+
config.bevelEnabled = !!bevel && bevel.enabled !== false;
|
|
2798
2246
|
if (bevel) {
|
|
2799
2247
|
if (bevel.depth !== void 0) config.bevelDepth = Math.round(bevel.depth * ratio);
|
|
2800
2248
|
if (bevel.highlight !== void 0) config.bevelHighlight = bevel.highlight;
|
|
@@ -2813,17 +2261,19 @@ function _buildConfig(effect, text, fontSize, canvasWidth, canvasHeight, time, c
|
|
|
2813
2261
|
if (bevel.focalLength !== void 0) config.bevelFocalLength = bevel.focalLength;
|
|
2814
2262
|
}
|
|
2815
2263
|
if (effect.stack) {
|
|
2816
|
-
config.stackEnabled = !!effect.stack.count;
|
|
2264
|
+
config.stackEnabled = effect.stack.enabled !== false && !!effect.stack.count;
|
|
2817
2265
|
if (effect.stack.count !== void 0) config.stackCount = effect.stack.count;
|
|
2818
2266
|
if (effect.stack.offsetX !== void 0) config.stackOffsetX = effect.stack.offsetX * ratio;
|
|
2819
2267
|
if (effect.stack.offsetY !== void 0) config.stackOffsetY = effect.stack.offsetY * ratio;
|
|
2820
|
-
if (effect.stack.opacityDecay !== void 0)
|
|
2268
|
+
if (effect.stack.opacityDecay !== void 0) {
|
|
2269
|
+
config.stackOpacityDecay = effect.stack.opacityDecay <= 1 ? effect.stack.opacityDecay * 100 : effect.stack.opacityDecay;
|
|
2270
|
+
}
|
|
2821
2271
|
if (effect.stack.color1 !== void 0) config.stackColor1 = effect.stack.color1;
|
|
2822
2272
|
if (effect.stack.color2 !== void 0) config.stackColor2 = effect.stack.color2;
|
|
2823
2273
|
if (effect.stack.color3 !== void 0) config.stackColor3 = effect.stack.color3;
|
|
2824
2274
|
if (effect.stack.color4 !== void 0) config.stackColor4 = effect.stack.color4;
|
|
2825
2275
|
}
|
|
2826
|
-
config.panelEnabled = !!panel;
|
|
2276
|
+
config.panelEnabled = !!panel && panel.enabled !== false;
|
|
2827
2277
|
if (panel) {
|
|
2828
2278
|
if (panel.color !== void 0) config.panelColor = panel.color;
|
|
2829
2279
|
if (panel.opacity !== void 0) config.panelOpacity = panel.opacity;
|
|
@@ -2832,16 +2282,17 @@ function _buildConfig(effect, text, fontSize, canvasWidth, canvasHeight, time, c
|
|
|
2832
2282
|
else if (panel.paddingX !== void 0) config.panelPaddingX = panel.paddingX * ratio;
|
|
2833
2283
|
if (panel.padding?.y !== void 0) config.panelPaddingY = panel.padding.y * ratio;
|
|
2834
2284
|
else if (panel.paddingY !== void 0) config.panelPaddingY = panel.paddingY * ratio;
|
|
2835
|
-
if (panel.stroke
|
|
2836
|
-
config.panelStrokeEnabled =
|
|
2285
|
+
if (panel.stroke) {
|
|
2286
|
+
config.panelStrokeEnabled = panel.stroke.enabled !== false;
|
|
2837
2287
|
if (panel.stroke.color !== void 0) config.panelStrokeColor = panel.stroke.color;
|
|
2838
2288
|
if (panel.stroke.width !== void 0) config.panelStrokeWidth = panel.stroke.width * ratio;
|
|
2839
2289
|
}
|
|
2840
2290
|
}
|
|
2841
|
-
if (effect.glows) {
|
|
2842
|
-
|
|
2291
|
+
if (effect.glows || effect.glow) {
|
|
2292
|
+
const sourceGlows = effect.glows ?? [effect.glow];
|
|
2293
|
+
config.glowLayers = sourceGlows.map((g) => {
|
|
2843
2294
|
const mappedGlow = {
|
|
2844
|
-
enabled:
|
|
2295
|
+
enabled: g.enabled !== false,
|
|
2845
2296
|
color: g.color,
|
|
2846
2297
|
blur: typeof g.blur === "number" ? g.blur * ratio : g.blur ?? 0,
|
|
2847
2298
|
opacity: g.opacity,
|
|
@@ -2852,15 +2303,6 @@ function _buildConfig(effect, text, fontSize, canvasWidth, canvasHeight, time, c
|
|
|
2852
2303
|
return mappedGlow;
|
|
2853
2304
|
});
|
|
2854
2305
|
}
|
|
2855
|
-
const rawEffect = effect;
|
|
2856
|
-
if (rawEffect.customRenderer !== void 0) config.customRenderer = rawEffect.customRenderer;
|
|
2857
|
-
if (rawEffect.inkColor !== void 0) config.inkColor = rawEffect.inkColor;
|
|
2858
|
-
if (rawEffect.bristleDensity !== void 0) config.bristleDensity = rawEffect.bristleDensity;
|
|
2859
|
-
if (rawEffect.bristleSkipRate !== void 0) config.bristleSkipRate = rawEffect.bristleSkipRate;
|
|
2860
|
-
if (rawEffect.dripRate !== void 0) config.dripRate = rawEffect.dripRate;
|
|
2861
|
-
if (rawEffect.dripMaxLength !== void 0) config.dripMaxLength = rawEffect.dripMaxLength;
|
|
2862
|
-
if (rawEffect.grainDensity !== void 0) config.grainDensity = rawEffect.grainDensity;
|
|
2863
|
-
if (rawEffect.skewX !== void 0) config.skewX = rawEffect.skewX;
|
|
2864
2306
|
const standardKeys = /* @__PURE__ */ new Set([
|
|
2865
2307
|
"id",
|
|
2866
2308
|
"name",
|
|
@@ -2953,15 +2395,7 @@ function _buildConfig(effect, text, fontSize, canvasWidth, canvasHeight, time, c
|
|
|
2953
2395
|
"textPosX",
|
|
2954
2396
|
"textPosY",
|
|
2955
2397
|
"autoFitText",
|
|
2956
|
-
"wrapText"
|
|
2957
|
-
"customRenderer",
|
|
2958
|
-
"inkColor",
|
|
2959
|
-
"bristleDensity",
|
|
2960
|
-
"bristleSkipRate",
|
|
2961
|
-
"dripRate",
|
|
2962
|
-
"dripMaxLength",
|
|
2963
|
-
"grainDensity",
|
|
2964
|
-
"skewX"
|
|
2398
|
+
"wrapText"
|
|
2965
2399
|
]);
|
|
2966
2400
|
for (const key of Object.keys(effect)) {
|
|
2967
2401
|
if (!standardKeys.has(key)) {
|
|
@@ -3383,170 +2817,6 @@ function createPulseOpacityTrack(layerId) {
|
|
|
3383
2817
|
};
|
|
3384
2818
|
}
|
|
3385
2819
|
|
|
3386
|
-
// src/compositor/index.ts
|
|
3387
|
-
var VERTEX_SRC = `#version 300 es
|
|
3388
|
-
in vec2 a_pos;
|
|
3389
|
-
in vec2 a_uv;
|
|
3390
|
-
out vec2 v_uv;
|
|
3391
|
-
void main() {
|
|
3392
|
-
v_uv = a_uv;
|
|
3393
|
-
gl_Position = vec4(a_pos, 0.0, 1.0);
|
|
3394
|
-
}
|
|
3395
|
-
`;
|
|
3396
|
-
var FRAGMENT_SRC = `#version 300 es
|
|
3397
|
-
precision highp float;
|
|
3398
|
-
in vec2 v_uv;
|
|
3399
|
-
uniform sampler2D u_tex;
|
|
3400
|
-
uniform vec2 u_texel;
|
|
3401
|
-
uniform float u_blur;
|
|
3402
|
-
uniform float u_bloom;
|
|
3403
|
-
uniform float u_bloomThreshold;
|
|
3404
|
-
out vec4 outColor;
|
|
3405
|
-
|
|
3406
|
-
void main() {
|
|
3407
|
-
vec4 c = texture(u_tex, v_uv);
|
|
3408
|
-
if (u_blur < 0.5 && u_bloom < 0.01) {
|
|
3409
|
-
outColor = c;
|
|
3410
|
-
return;
|
|
3411
|
-
}
|
|
3412
|
-
vec4 sum = c;
|
|
3413
|
-
float w = 0.0;
|
|
3414
|
-
if (u_blur >= 0.5) {
|
|
3415
|
-
sum = vec4(0.0);
|
|
3416
|
-
w = 0.0;
|
|
3417
|
-
for (int x = -2; x <= 2; x++) {
|
|
3418
|
-
for (int y = -2; y <= 2; y++) {
|
|
3419
|
-
vec2 off = vec2(float(x), float(y)) * u_texel * u_blur;
|
|
3420
|
-
vec4 s = texture(u_tex, v_uv + off);
|
|
3421
|
-
float weight = 1.0 / (1.0 + float(x*x + y*y));
|
|
3422
|
-
sum += s * weight;
|
|
3423
|
-
w += weight;
|
|
3424
|
-
}
|
|
3425
|
-
}
|
|
3426
|
-
sum /= w;
|
|
3427
|
-
}
|
|
3428
|
-
vec3 bloom = vec3(0.0);
|
|
3429
|
-
if (u_bloom > 0.01) {
|
|
3430
|
-
float lum = dot(sum.rgb, vec3(0.299, 0.587, 0.114));
|
|
3431
|
-
if (lum > u_bloomThreshold) {
|
|
3432
|
-
bloom = sum.rgb * u_bloom * (lum - u_bloomThreshold);
|
|
3433
|
-
}
|
|
3434
|
-
}
|
|
3435
|
-
outColor = vec4(clamp(sum.rgb + bloom, 0.0, 1.0), c.a);
|
|
3436
|
-
}
|
|
3437
|
-
`;
|
|
3438
|
-
var WebGLCompositor = class {
|
|
3439
|
-
gl = null;
|
|
3440
|
-
program = null;
|
|
3441
|
-
vao = null;
|
|
3442
|
-
texture = null;
|
|
3443
|
-
isSupported;
|
|
3444
|
-
constructor() {
|
|
3445
|
-
if (typeof document === "undefined") {
|
|
3446
|
-
this.isSupported = false;
|
|
3447
|
-
return;
|
|
3448
|
-
}
|
|
3449
|
-
const canvas = document.createElement("canvas");
|
|
3450
|
-
canvas.width = 2;
|
|
3451
|
-
canvas.height = 2;
|
|
3452
|
-
const gl = canvas.getContext("webgl2", { premultipliedAlpha: true, alpha: true });
|
|
3453
|
-
if (!gl) {
|
|
3454
|
-
this.isSupported = false;
|
|
3455
|
-
return;
|
|
3456
|
-
}
|
|
3457
|
-
this.gl = gl;
|
|
3458
|
-
this.isSupported = this.initProgram(gl);
|
|
3459
|
-
}
|
|
3460
|
-
initProgram(gl) {
|
|
3461
|
-
const vs = this.compileShader(gl, gl.VERTEX_SHADER, VERTEX_SRC);
|
|
3462
|
-
const fs = this.compileShader(gl, gl.FRAGMENT_SHADER, FRAGMENT_SRC);
|
|
3463
|
-
if (!vs || !fs) return false;
|
|
3464
|
-
const program = gl.createProgram();
|
|
3465
|
-
if (!program) return false;
|
|
3466
|
-
gl.attachShader(program, vs);
|
|
3467
|
-
gl.attachShader(program, fs);
|
|
3468
|
-
gl.linkProgram(program);
|
|
3469
|
-
if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {
|
|
3470
|
-
console.warn("Compositor program link failed", gl.getProgramInfoLog(program));
|
|
3471
|
-
return false;
|
|
3472
|
-
}
|
|
3473
|
-
this.program = program;
|
|
3474
|
-
const positions = new Float32Array([-1, -1, 0, 1, 1, -1, 1, 1, -1, 1, 0, 0, 1, 1, 1, 0]);
|
|
3475
|
-
const vao = gl.createVertexArray();
|
|
3476
|
-
const vbo = gl.createBuffer();
|
|
3477
|
-
gl.bindVertexArray(vao);
|
|
3478
|
-
gl.bindBuffer(gl.ARRAY_BUFFER, vbo);
|
|
3479
|
-
gl.bufferData(gl.ARRAY_BUFFER, positions, gl.STATIC_DRAW);
|
|
3480
|
-
const locPos = gl.getAttribLocation(program, "a_pos");
|
|
3481
|
-
const locUv = gl.getAttribLocation(program, "a_uv");
|
|
3482
|
-
gl.enableVertexAttribArray(locPos);
|
|
3483
|
-
gl.vertexAttribPointer(locPos, 2, gl.FLOAT, false, 16, 0);
|
|
3484
|
-
gl.enableVertexAttribArray(locUv);
|
|
3485
|
-
gl.vertexAttribPointer(locUv, 2, gl.FLOAT, false, 16, 8);
|
|
3486
|
-
gl.bindVertexArray(null);
|
|
3487
|
-
this.vao = vao;
|
|
3488
|
-
this.texture = gl.createTexture();
|
|
3489
|
-
return true;
|
|
3490
|
-
}
|
|
3491
|
-
compileShader(gl, type, source) {
|
|
3492
|
-
const shader = gl.createShader(type);
|
|
3493
|
-
if (!shader) return null;
|
|
3494
|
-
gl.shaderSource(shader, source);
|
|
3495
|
-
gl.compileShader(shader);
|
|
3496
|
-
if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
|
|
3497
|
-
console.warn(gl.getShaderInfoLog(shader));
|
|
3498
|
-
return null;
|
|
3499
|
-
}
|
|
3500
|
-
return shader;
|
|
3501
|
-
}
|
|
3502
|
-
renderToContext(targetCtx, source, settings) {
|
|
3503
|
-
const gl = this.gl;
|
|
3504
|
-
const program = this.program;
|
|
3505
|
-
if (!gl || !program || !this.isSupported) {
|
|
3506
|
-
targetCtx.clearRect(0, 0, source.width, source.height);
|
|
3507
|
-
targetCtx.drawImage(source, 0, 0);
|
|
3508
|
-
return;
|
|
3509
|
-
}
|
|
3510
|
-
const w = source.width;
|
|
3511
|
-
const h = source.height;
|
|
3512
|
-
const canvas = gl.canvas;
|
|
3513
|
-
if (canvas.width !== w || canvas.height !== h) {
|
|
3514
|
-
canvas.width = w;
|
|
3515
|
-
canvas.height = h;
|
|
3516
|
-
}
|
|
3517
|
-
gl.viewport(0, 0, w, h);
|
|
3518
|
-
gl.clearColor(0, 0, 0, 0);
|
|
3519
|
-
gl.clear(gl.COLOR_BUFFER_BIT);
|
|
3520
|
-
gl.useProgram(program);
|
|
3521
|
-
gl.activeTexture(gl.TEXTURE0);
|
|
3522
|
-
gl.bindTexture(gl.TEXTURE_2D, this.texture);
|
|
3523
|
-
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
|
|
3524
|
-
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
|
|
3525
|
-
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
|
|
3526
|
-
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
|
|
3527
|
-
gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, true);
|
|
3528
|
-
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, source);
|
|
3529
|
-
gl.uniform1i(gl.getUniformLocation(program, "u_tex"), 0);
|
|
3530
|
-
gl.uniform2f(gl.getUniformLocation(program, "u_texel"), 1 / w, 1 / h);
|
|
3531
|
-
gl.uniform1f(gl.getUniformLocation(program, "u_blur"), settings.blur ?? 0);
|
|
3532
|
-
gl.uniform1f(gl.getUniformLocation(program, "u_bloom"), settings.bloom ?? 0);
|
|
3533
|
-
gl.uniform1f(gl.getUniformLocation(program, "u_bloomThreshold"), settings.bloomThreshold ?? 0.6);
|
|
3534
|
-
gl.bindVertexArray(this.vao);
|
|
3535
|
-
gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
|
|
3536
|
-
gl.bindVertexArray(null);
|
|
3537
|
-
targetCtx.clearRect(0, 0, w, h);
|
|
3538
|
-
targetCtx.drawImage(canvas, 0, 0);
|
|
3539
|
-
}
|
|
3540
|
-
dispose() {
|
|
3541
|
-
const gl = this.gl;
|
|
3542
|
-
if (!gl) return;
|
|
3543
|
-
if (this.texture) gl.deleteTexture(this.texture);
|
|
3544
|
-
if (this.program) gl.deleteProgram(this.program);
|
|
3545
|
-
if (this.vao) gl.deleteVertexArray(this.vao);
|
|
3546
|
-
this.gl = null;
|
|
3547
|
-
}
|
|
3548
|
-
};
|
|
3549
|
-
|
|
3550
2820
|
// src/engine/mask.ts
|
|
3551
2821
|
function applyMaskReveal(ctx, doc, width, height) {
|
|
3552
2822
|
const maskLayer = doc.effectLayers.find((l) => l.type === "mask" && l.enabled);
|
|
@@ -3574,18 +2844,6 @@ function applyMaskReveal(ctx, doc, width, height) {
|
|
|
3574
2844
|
}
|
|
3575
2845
|
|
|
3576
2846
|
// src/engine/evaluate.ts
|
|
3577
|
-
var sharedCompositor = null;
|
|
3578
|
-
function getCompositor() {
|
|
3579
|
-
if (typeof document === "undefined") return null;
|
|
3580
|
-
if (!sharedCompositor) {
|
|
3581
|
-
sharedCompositor = new WebGLCompositor();
|
|
3582
|
-
}
|
|
3583
|
-
return sharedCompositor;
|
|
3584
|
-
}
|
|
3585
|
-
function disposeSharedCompositor() {
|
|
3586
|
-
sharedCompositor?.dispose();
|
|
3587
|
-
sharedCompositor = null;
|
|
3588
|
-
}
|
|
3589
2847
|
function evaluateScene(doc, time, ctx, options = {}) {
|
|
3590
2848
|
const animated = applyTimelineAtTime(doc, time);
|
|
3591
2849
|
const cfg = sceneToConfig(animated);
|
|
@@ -3612,11 +2870,21 @@ function evaluateScene(doc, time, ctx, options = {}) {
|
|
|
3612
2870
|
tctx.clearRect(0, 0, w, h);
|
|
3613
2871
|
renderTextEffectCore(tctx, cfg);
|
|
3614
2872
|
applyMaskReveal(tctx, animated, w, h);
|
|
3615
|
-
|
|
3616
|
-
if (
|
|
3617
|
-
|
|
2873
|
+
ctx.clearRect(0, 0, w, h);
|
|
2874
|
+
if (supportsCtxFilter()) {
|
|
2875
|
+
ctx.save();
|
|
2876
|
+
const blur = Math.max(0, comp.blur);
|
|
2877
|
+
const bloom = Math.max(0, comp.bloom);
|
|
2878
|
+
if (blur > 0) ctx.filter = `blur(${blur}px)`;
|
|
2879
|
+
ctx.drawImage(temp, 0, 0);
|
|
2880
|
+
if (bloom > 0) {
|
|
2881
|
+
ctx.globalCompositeOperation = "screen";
|
|
2882
|
+
ctx.globalAlpha = Math.min(0.8, bloom * 0.25);
|
|
2883
|
+
ctx.filter = `blur(${Math.max(1, bloom * 4)}px)`;
|
|
2884
|
+
ctx.drawImage(temp, 0, 0);
|
|
2885
|
+
}
|
|
2886
|
+
ctx.restore();
|
|
3618
2887
|
} else {
|
|
3619
|
-
ctx.clearRect(0, 0, w, h);
|
|
3620
2888
|
ctx.drawImage(temp, 0, 0);
|
|
3621
2889
|
}
|
|
3622
2890
|
CanvasDevice.release(temp);
|
|
@@ -3654,14 +2922,12 @@ function resetSceneTime(doc) {
|
|
|
3654
2922
|
|
|
3655
2923
|
export {
|
|
3656
2924
|
SCENE_VERSION,
|
|
2925
|
+
SCENE_SCHEMA_VERSION,
|
|
3657
2926
|
DEFAULT_CANVAS_WIDTH,
|
|
3658
2927
|
DEFAULT_CANVAS_HEIGHT,
|
|
3659
2928
|
DEFAULT_FONT_SIZE,
|
|
3660
2929
|
DEFAULT_FPS,
|
|
3661
2930
|
DEFAULT_DURATION,
|
|
3662
|
-
CUSTOM_ENGINE_IDS,
|
|
3663
|
-
LEGACY_RENDERER_MAP,
|
|
3664
|
-
ENGINE_ID_TO_LEGACY,
|
|
3665
2931
|
createEmptyScene,
|
|
3666
2932
|
newLayerId,
|
|
3667
2933
|
COMPOSITION_PRESETS,
|
|
@@ -3681,22 +2947,20 @@ export {
|
|
|
3681
2947
|
supportsRoundRect,
|
|
3682
2948
|
supportsLetterSpacing,
|
|
3683
2949
|
supportsOffscreenCanvas,
|
|
3684
|
-
supportsWebGL2,
|
|
3685
2950
|
createCanvas,
|
|
3686
2951
|
releaseCanvas,
|
|
3687
2952
|
_resetPlatformCache,
|
|
3688
2953
|
CanvasDevice,
|
|
3689
|
-
InkBrushEngine,
|
|
3690
2954
|
drawRoundedRect,
|
|
3691
2955
|
applyLetterSpacing,
|
|
3692
2956
|
restoreLetterSpacing,
|
|
3693
2957
|
renderTextEffectCore,
|
|
3694
2958
|
TextEffectRenderer,
|
|
3695
2959
|
defaultConfig,
|
|
2960
|
+
createBlankTextEffectConfig,
|
|
3696
2961
|
builtInPresets,
|
|
3697
2962
|
ensureDefaultTimeline,
|
|
3698
2963
|
cloneSceneWithNewIds,
|
|
3699
|
-
resolveCustomEngineId,
|
|
3700
2964
|
textEffectConfigToScene,
|
|
3701
2965
|
sceneToConfig,
|
|
3702
2966
|
syncCompositorFromScene,
|
|
@@ -3716,9 +2980,7 @@ export {
|
|
|
3716
2980
|
applyTimelineAtTime,
|
|
3717
2981
|
createDefaultRevealTrack,
|
|
3718
2982
|
createPulseOpacityTrack,
|
|
3719
|
-
WebGLCompositor,
|
|
3720
2983
|
applyMaskReveal,
|
|
3721
|
-
disposeSharedCompositor,
|
|
3722
2984
|
evaluateScene,
|
|
3723
2985
|
evaluateConfig,
|
|
3724
2986
|
advanceSceneTime,
|
|
@@ -3726,4 +2988,4 @@ export {
|
|
|
3726
2988
|
setSceneTime,
|
|
3727
2989
|
resetSceneTime
|
|
3728
2990
|
};
|
|
3729
|
-
//# sourceMappingURL=chunk-
|
|
2991
|
+
//# sourceMappingURL=chunk-E6O6LZME.js.map
|