@clypra-studio/engine 1.3.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 +1 -1
- 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 +11149 -23528
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2087 -7834
- package/dist/index.d.ts +2087 -7834
- package/dist/index.js +10059 -17971
- 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 +13 -16
- 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-BdQ3oRT4.d.cts +0 -139
- package/dist/index-BdQ3oRT4.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
|
@@ -38,12 +38,6 @@ module.exports = __toCommonJS(textEffects_exports);
|
|
|
38
38
|
var DEFAULT_CANVAS_WIDTH = 800;
|
|
39
39
|
var DEFAULT_CANVAS_HEIGHT = 200;
|
|
40
40
|
var DEFAULT_FONT_SIZE = 80;
|
|
41
|
-
var LEGACY_RENDERER_MAP = {
|
|
42
|
-
InkBrushEngine: "ink"
|
|
43
|
-
};
|
|
44
|
-
var ENGINE_ID_TO_LEGACY = {
|
|
45
|
-
ink: "InkBrushEngine"
|
|
46
|
-
};
|
|
47
41
|
function newLayerId() {
|
|
48
42
|
return `layer-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 7)}`;
|
|
49
43
|
}
|
|
@@ -237,10 +231,11 @@ function drawPerCharText(ctx, opts) {
|
|
|
237
231
|
ctx.restore();
|
|
238
232
|
}
|
|
239
233
|
function shouldUsePerCharFill(cfg) {
|
|
240
|
-
return !!cfg.perCharFillEnabled && cfg.fillType === "solid" &&
|
|
234
|
+
return !!cfg.perCharFillEnabled && cfg.fillType === "solid" && (cfg.charFillColors?.length ?? 0) > 0;
|
|
241
235
|
}
|
|
242
236
|
|
|
243
237
|
// src/platform.ts
|
|
238
|
+
var _ctxFilter = null;
|
|
244
239
|
var _roundRect = null;
|
|
245
240
|
var _offscreenCanvas = null;
|
|
246
241
|
function probe2d() {
|
|
@@ -251,6 +246,21 @@ function probe2d() {
|
|
|
251
246
|
return null;
|
|
252
247
|
}
|
|
253
248
|
}
|
|
249
|
+
function supportsCtxFilter() {
|
|
250
|
+
if (_ctxFilter !== null) return _ctxFilter;
|
|
251
|
+
const ctx = probe2d();
|
|
252
|
+
if (!ctx) {
|
|
253
|
+
_ctxFilter = false;
|
|
254
|
+
return false;
|
|
255
|
+
}
|
|
256
|
+
try {
|
|
257
|
+
ctx.filter = "blur(4px)";
|
|
258
|
+
_ctxFilter = typeof ctx.filter === "string" && ctx.filter.includes("blur");
|
|
259
|
+
} catch {
|
|
260
|
+
_ctxFilter = false;
|
|
261
|
+
}
|
|
262
|
+
return _ctxFilter;
|
|
263
|
+
}
|
|
254
264
|
function supportsRoundRect() {
|
|
255
265
|
if (_roundRect !== null) return _roundRect;
|
|
256
266
|
const ctx = probe2d();
|
|
@@ -283,7 +293,7 @@ function createCanvas(width, height) {
|
|
|
283
293
|
}
|
|
284
294
|
}
|
|
285
295
|
function releaseCanvas(canvas) {
|
|
286
|
-
if (canvas instanceof OffscreenCanvas) return;
|
|
296
|
+
if (typeof OffscreenCanvas !== "undefined" && canvas instanceof OffscreenCanvas) return;
|
|
287
297
|
canvas.width = 0;
|
|
288
298
|
canvas.height = 0;
|
|
289
299
|
}
|
|
@@ -328,363 +338,6 @@ var CanvasDevice = class {
|
|
|
328
338
|
}
|
|
329
339
|
};
|
|
330
340
|
|
|
331
|
-
// src/engine/procedural/utils.ts
|
|
332
|
-
function getCanvas2DContext(canvas) {
|
|
333
|
-
return canvas.getContext("2d");
|
|
334
|
-
}
|
|
335
|
-
function seededRandom(seed) {
|
|
336
|
-
let s = seed;
|
|
337
|
-
return function() {
|
|
338
|
-
s = s * 16807 % 2147483647;
|
|
339
|
-
return (s - 1) / 2147483646;
|
|
340
|
-
};
|
|
341
|
-
}
|
|
342
|
-
function textSeed(text) {
|
|
343
|
-
return text.split("").reduce((acc, c) => acc + c.charCodeAt(0), 0) * 9301 % 49297;
|
|
344
|
-
}
|
|
345
|
-
function hexToRgb(hex) {
|
|
346
|
-
const shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
|
|
347
|
-
const fullHex = hex.replace(shorthandRegex, (m, r, g, b) => r + r + g + g + b + b);
|
|
348
|
-
const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(fullHex);
|
|
349
|
-
return result ? {
|
|
350
|
-
r: parseInt(result[1], 16),
|
|
351
|
-
g: parseInt(result[2], 16),
|
|
352
|
-
b: parseInt(result[3], 16)
|
|
353
|
-
} : { r: 255, g: 255, b: 255 };
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
// src/engine/procedural/InkBrushEngine.ts
|
|
357
|
-
var InkBrushEngine = class {
|
|
358
|
-
cfg;
|
|
359
|
-
bristleLines = [];
|
|
360
|
-
grainDots = [];
|
|
361
|
-
drips = [];
|
|
362
|
-
constructor(config) {
|
|
363
|
-
const defaults = {
|
|
364
|
-
text: "INK",
|
|
365
|
-
effectName: "InkBrush",
|
|
366
|
-
fontFamily: "Bebas Neue",
|
|
367
|
-
fontWeight: 900,
|
|
368
|
-
fontStyle: "italic",
|
|
369
|
-
fontSize: 96,
|
|
370
|
-
letterSpacing: 2,
|
|
371
|
-
lineHeight: 1.1,
|
|
372
|
-
wrapText: true,
|
|
373
|
-
autoFitText: false,
|
|
374
|
-
perCharFillEnabled: false,
|
|
375
|
-
charFillColors: [],
|
|
376
|
-
fillType: "solid",
|
|
377
|
-
fillColor: "#FFFFFF",
|
|
378
|
-
fillGradientAngle: 90,
|
|
379
|
-
fillGradientStops: [],
|
|
380
|
-
patternType: "chalk",
|
|
381
|
-
strokeEnabled: false,
|
|
382
|
-
strokeColor: "#000000",
|
|
383
|
-
strokeWidth: 0,
|
|
384
|
-
strokePosition: "outside",
|
|
385
|
-
strokeOpacity: 100,
|
|
386
|
-
strokeLineJoin: "round",
|
|
387
|
-
strokeBlur: 0,
|
|
388
|
-
strokeType: "single",
|
|
389
|
-
strokeColorSecondary: "#FFFFFF",
|
|
390
|
-
strokeWidthSecondary: 4,
|
|
391
|
-
strokeFadeRange: 0,
|
|
392
|
-
glowLayers: [],
|
|
393
|
-
shadowEnabled: false,
|
|
394
|
-
shadowColor: "#000000",
|
|
395
|
-
shadowBlur: 10,
|
|
396
|
-
shadowOffsetX: 5,
|
|
397
|
-
shadowOffsetY: 5,
|
|
398
|
-
shadowOpacity: 80,
|
|
399
|
-
shadowType: "drop",
|
|
400
|
-
bevelEnabled: false,
|
|
401
|
-
bevelDepth: 5,
|
|
402
|
-
bevelHighlight: "#FFFFFF",
|
|
403
|
-
bevelShadow: "#000000",
|
|
404
|
-
bevelDirection: "bottom-right",
|
|
405
|
-
bevelCoreColor: "#000000",
|
|
406
|
-
bevelEdgeColor: "#2A2A38",
|
|
407
|
-
bevelEdgeWidth: 0,
|
|
408
|
-
bevelBlur: 0,
|
|
409
|
-
bevelBlurColor: "#000000",
|
|
410
|
-
bevelPerspectiveEnabled: false,
|
|
411
|
-
bevelVanishingPointX: 40,
|
|
412
|
-
bevelVanishingPointY: 80,
|
|
413
|
-
bevelFocalLength: 400,
|
|
414
|
-
stackEnabled: false,
|
|
415
|
-
stackCount: 3,
|
|
416
|
-
stackOffsetX: 10,
|
|
417
|
-
stackOffsetY: -10,
|
|
418
|
-
stackOpacityDecay: 20,
|
|
419
|
-
stackColor1: "#FF7C00",
|
|
420
|
-
stackColor2: "#00FFDD",
|
|
421
|
-
stackColor3: "#FF00AA",
|
|
422
|
-
stackColor4: "#AA00FF",
|
|
423
|
-
panelEnabled: false,
|
|
424
|
-
panelColor: "#1E1E26",
|
|
425
|
-
panelOpacity: 80,
|
|
426
|
-
panelRadius: 12,
|
|
427
|
-
panelPaddingX: 40,
|
|
428
|
-
panelPaddingY: 20,
|
|
429
|
-
panelStrokeEnabled: false,
|
|
430
|
-
panelStrokeColor: "#2A2A38",
|
|
431
|
-
panelStrokeWidth: 2,
|
|
432
|
-
canvasWidth: DEFAULT_CANVAS_WIDTH,
|
|
433
|
-
canvasHeight: DEFAULT_CANVAS_HEIGHT,
|
|
434
|
-
textPosX: "center",
|
|
435
|
-
textPosY: "middle",
|
|
436
|
-
inkColor: "#FFFFFF",
|
|
437
|
-
bristleDensity: 0.8,
|
|
438
|
-
bristleSkipRate: 0.2,
|
|
439
|
-
dripRate: 0.3,
|
|
440
|
-
dripMaxLength: 40,
|
|
441
|
-
grainDensity: 0.15,
|
|
442
|
-
skewX: -0.2,
|
|
443
|
-
customRenderer: "InkBrushEngine"
|
|
444
|
-
};
|
|
445
|
-
this.cfg = {
|
|
446
|
-
...defaults,
|
|
447
|
-
...config
|
|
448
|
-
};
|
|
449
|
-
this.precomputeData();
|
|
450
|
-
}
|
|
451
|
-
precomputeData() {
|
|
452
|
-
const { text, fontFamily, fontWeight, fontStyle, fontSize, letterSpacing, lineHeight, canvasWidth, canvasHeight, textPosX, textPosY, bristleDensity, bristleSkipRate, dripRate, dripMaxLength, grainDensity, skewX } = this.cfg;
|
|
453
|
-
const width = canvasWidth;
|
|
454
|
-
const height = canvasHeight;
|
|
455
|
-
const rand = seededRandom(textSeed(text));
|
|
456
|
-
let canvas = createCanvas(width, height);
|
|
457
|
-
canvas.width = width;
|
|
458
|
-
canvas.height = height;
|
|
459
|
-
const ctx = getCanvas2DContext(canvas);
|
|
460
|
-
if (!ctx) return;
|
|
461
|
-
const lines = text.split("\n");
|
|
462
|
-
const numLines = lines.length;
|
|
463
|
-
const textBlockHeight = fontSize + (numLines - 1) * fontSize * lineHeight;
|
|
464
|
-
let startX = width / 2;
|
|
465
|
-
let align = "center";
|
|
466
|
-
if (textPosX === "left") {
|
|
467
|
-
startX = 50;
|
|
468
|
-
align = "left";
|
|
469
|
-
} else if (textPosX === "right") {
|
|
470
|
-
startX = width - 50;
|
|
471
|
-
align = "right";
|
|
472
|
-
}
|
|
473
|
-
ctx.textAlign = align;
|
|
474
|
-
ctx.textBaseline = "alphabetic";
|
|
475
|
-
const fontStr = `${fontStyle} ${fontWeight} ${fontSize}px "${fontFamily}"`;
|
|
476
|
-
ctx.font = fontStr;
|
|
477
|
-
if (letterSpacing !== 0) {
|
|
478
|
-
ctx.letterSpacing = `${letterSpacing}px`;
|
|
479
|
-
}
|
|
480
|
-
let startY = (height - textBlockHeight) / 2 + fontSize * 0.85;
|
|
481
|
-
if (textPosY === "top") {
|
|
482
|
-
startY = 40 + fontSize * 0.85;
|
|
483
|
-
} else if (textPosY === "bottom") {
|
|
484
|
-
startY = height - 40 - textBlockHeight + fontSize * 0.85;
|
|
485
|
-
}
|
|
486
|
-
ctx.save();
|
|
487
|
-
if (skewX !== 0) {
|
|
488
|
-
ctx.transform(1, 0, skewX, 1, 0, 0);
|
|
489
|
-
}
|
|
490
|
-
ctx.fillStyle = "#FFFFFF";
|
|
491
|
-
lines.forEach((line, index) => {
|
|
492
|
-
const py = startY + index * fontSize * lineHeight;
|
|
493
|
-
ctx.fillText(line, startX, py);
|
|
494
|
-
});
|
|
495
|
-
ctx.restore();
|
|
496
|
-
const imgData = ctx.getImageData(0, 0, width, height);
|
|
497
|
-
const pixels = imgData.data;
|
|
498
|
-
let minY = height;
|
|
499
|
-
let maxY = 0;
|
|
500
|
-
for (let y = 0; y < height; y++) {
|
|
501
|
-
for (let x = 0; x < width; x++) {
|
|
502
|
-
const idx = (y * width + x) * 4;
|
|
503
|
-
if (pixels[idx + 3] > 128) {
|
|
504
|
-
if (y < minY) minY = y;
|
|
505
|
-
if (y > maxY) maxY = y;
|
|
506
|
-
}
|
|
507
|
-
}
|
|
508
|
-
}
|
|
509
|
-
if (minY >= maxY) return;
|
|
510
|
-
const step = Math.max(1, Math.min(3, 1 / bristleDensity));
|
|
511
|
-
for (let y = minY; y <= maxY; y += step) {
|
|
512
|
-
const segments = [];
|
|
513
|
-
let inSegment = false;
|
|
514
|
-
let xStart = 0;
|
|
515
|
-
const targetY = Math.floor(y);
|
|
516
|
-
for (let x = 0; x < width; x++) {
|
|
517
|
-
const idx = (targetY * width + x) * 4;
|
|
518
|
-
const isInside = pixels[idx + 3] > 128;
|
|
519
|
-
if (isInside && !inSegment) {
|
|
520
|
-
inSegment = true;
|
|
521
|
-
xStart = x;
|
|
522
|
-
} else if (!isInside && inSegment) {
|
|
523
|
-
inSegment = false;
|
|
524
|
-
segments.push({ xStart, xEnd: x - 1 });
|
|
525
|
-
}
|
|
526
|
-
}
|
|
527
|
-
if (inSegment) {
|
|
528
|
-
segments.push({ xStart, xEnd: width - 1 });
|
|
529
|
-
}
|
|
530
|
-
for (const seg of segments) {
|
|
531
|
-
if (rand() < bristleSkipRate) continue;
|
|
532
|
-
const segW = seg.xEnd - seg.xStart;
|
|
533
|
-
const startLimit = seg.xStart + rand() * Math.min(15, segW * 0.2);
|
|
534
|
-
const endLimit = seg.xEnd - rand() * Math.min(15, segW * 0.2);
|
|
535
|
-
if (startLimit >= endLimit) continue;
|
|
536
|
-
const opacity = 0.4 + rand() * 0.6;
|
|
537
|
-
const lw = 0.5 + rand() * 1.5;
|
|
538
|
-
const hasGap = rand() < 0.1;
|
|
539
|
-
if (hasGap) {
|
|
540
|
-
const gapPct = 0.3 + rand() * 0.4;
|
|
541
|
-
const gapLen = 5 + rand() * 15;
|
|
542
|
-
const midX = startLimit + (endLimit - startLimit) * gapPct;
|
|
543
|
-
const p1Start = startLimit;
|
|
544
|
-
const p1End = Math.max(startLimit, midX - gapLen / 2);
|
|
545
|
-
const p2Start = Math.min(endLimit, midX + gapLen / 2);
|
|
546
|
-
const p2End = endLimit;
|
|
547
|
-
if (p1End > p1Start) {
|
|
548
|
-
this.bristleLines.push({ y: targetY, x0: p1Start, x1: p1End, opacity, lineWidth: lw });
|
|
549
|
-
}
|
|
550
|
-
if (p2End > p2Start) {
|
|
551
|
-
this.bristleLines.push({ y: targetY, x0: p2Start, x1: p2End, opacity, lineWidth: lw });
|
|
552
|
-
}
|
|
553
|
-
} else {
|
|
554
|
-
this.bristleLines.push({ y: targetY, x0: startLimit, x1: endLimit, opacity, lineWidth: lw });
|
|
555
|
-
}
|
|
556
|
-
}
|
|
557
|
-
}
|
|
558
|
-
for (let y = minY; y <= maxY; y++) {
|
|
559
|
-
for (let x = 0; x < width; x++) {
|
|
560
|
-
const idx = (y * width + x) * 4;
|
|
561
|
-
if (pixels[idx + 3] > 128) {
|
|
562
|
-
if (rand() < grainDensity) {
|
|
563
|
-
this.grainDots.push({
|
|
564
|
-
x,
|
|
565
|
-
y,
|
|
566
|
-
opacity: 0.2 + rand() * 0.3
|
|
567
|
-
});
|
|
568
|
-
}
|
|
569
|
-
}
|
|
570
|
-
}
|
|
571
|
-
}
|
|
572
|
-
const bottomRowForCol = new Array(width).fill(-1);
|
|
573
|
-
for (let x = 0; x < width; x++) {
|
|
574
|
-
for (let y = height - 1; y >= 0; y--) {
|
|
575
|
-
const idx = (y * width + x) * 4;
|
|
576
|
-
if (pixels[idx + 3] > 128) {
|
|
577
|
-
bottomRowForCol[x] = y;
|
|
578
|
-
break;
|
|
579
|
-
}
|
|
580
|
-
}
|
|
581
|
-
}
|
|
582
|
-
for (let x = 0; x < width; x++) {
|
|
583
|
-
const sY = bottomRowForCol[x];
|
|
584
|
-
if (sY === -1) continue;
|
|
585
|
-
if (rand() < dripRate) {
|
|
586
|
-
const length = 8 + rand() * (dripMaxLength - 8);
|
|
587
|
-
const startWidth = 1 + rand() * 1;
|
|
588
|
-
const endWidth = rand() < 0.5 ? startWidth : 0.5;
|
|
589
|
-
const startOpacity = 0.6 + rand() * 0.3;
|
|
590
|
-
const hasBlob = rand() < 0.6;
|
|
591
|
-
const blobRadius = 1.5 + rand() * 1.5;
|
|
592
|
-
this.drips.push({
|
|
593
|
-
x,
|
|
594
|
-
startY: sY,
|
|
595
|
-
length,
|
|
596
|
-
startWidth,
|
|
597
|
-
endWidth,
|
|
598
|
-
startOpacity,
|
|
599
|
-
hasBlob,
|
|
600
|
-
blobRadius
|
|
601
|
-
});
|
|
602
|
-
}
|
|
603
|
-
}
|
|
604
|
-
}
|
|
605
|
-
advanceSteps(steps) {
|
|
606
|
-
}
|
|
607
|
-
drawFrame(ctx) {
|
|
608
|
-
const { text, fontFamily, fontWeight, fontStyle, fontSize, letterSpacing, lineHeight, canvasWidth, canvasHeight, textPosX, textPosY, skewX, inkColor } = this.cfg;
|
|
609
|
-
const width = canvasWidth;
|
|
610
|
-
const height = canvasHeight;
|
|
611
|
-
ctx.clearRect(0, 0, width, height);
|
|
612
|
-
ctx.imageSmoothingEnabled = true;
|
|
613
|
-
const lines = text.split("\n");
|
|
614
|
-
const numLines = lines.length;
|
|
615
|
-
const textBlockHeight = fontSize + (numLines - 1) * fontSize * lineHeight;
|
|
616
|
-
let startX = width / 2;
|
|
617
|
-
let align = "center";
|
|
618
|
-
if (textPosX === "left") {
|
|
619
|
-
startX = 50;
|
|
620
|
-
align = "left";
|
|
621
|
-
} else if (textPosX === "right") {
|
|
622
|
-
startX = width - 50;
|
|
623
|
-
align = "right";
|
|
624
|
-
}
|
|
625
|
-
ctx.textAlign = align;
|
|
626
|
-
ctx.textBaseline = "alphabetic";
|
|
627
|
-
const fontStr = `${fontStyle} ${fontWeight} ${fontSize}px "${fontFamily}"`;
|
|
628
|
-
ctx.font = fontStr;
|
|
629
|
-
if (letterSpacing !== 0) {
|
|
630
|
-
ctx.letterSpacing = `${letterSpacing}px`;
|
|
631
|
-
}
|
|
632
|
-
let startY = (height - textBlockHeight) / 2 + fontSize * 0.85;
|
|
633
|
-
if (textPosY === "top") {
|
|
634
|
-
startY = 40 + fontSize * 0.85;
|
|
635
|
-
} else if (textPosY === "bottom") {
|
|
636
|
-
startY = height - 40 - textBlockHeight + fontSize * 0.85;
|
|
637
|
-
}
|
|
638
|
-
ctx.save();
|
|
639
|
-
if (skewX !== 0) {
|
|
640
|
-
ctx.transform(1, 0, skewX, 1, 0, 0);
|
|
641
|
-
}
|
|
642
|
-
ctx.fillStyle = inkColor;
|
|
643
|
-
lines.forEach((line, index) => {
|
|
644
|
-
const py = startY + index * fontSize * lineHeight;
|
|
645
|
-
ctx.fillText(line, startX, py);
|
|
646
|
-
});
|
|
647
|
-
ctx.restore();
|
|
648
|
-
ctx.save();
|
|
649
|
-
ctx.globalCompositeOperation = "source-in";
|
|
650
|
-
ctx.strokeStyle = inkColor;
|
|
651
|
-
this.bristleLines.forEach((line) => {
|
|
652
|
-
ctx.globalAlpha = line.opacity;
|
|
653
|
-
ctx.lineWidth = line.lineWidth;
|
|
654
|
-
ctx.beginPath();
|
|
655
|
-
ctx.moveTo(line.x0, line.y);
|
|
656
|
-
ctx.lineTo(line.x1, line.y);
|
|
657
|
-
ctx.stroke();
|
|
658
|
-
});
|
|
659
|
-
ctx.fillStyle = inkColor;
|
|
660
|
-
this.grainDots.forEach((dot) => {
|
|
661
|
-
ctx.globalAlpha = dot.opacity;
|
|
662
|
-
ctx.fillRect(dot.x, dot.y, 1, 1);
|
|
663
|
-
});
|
|
664
|
-
ctx.restore();
|
|
665
|
-
const inkRgb = hexToRgb(inkColor);
|
|
666
|
-
ctx.save();
|
|
667
|
-
this.drips.forEach((drip) => {
|
|
668
|
-
const grad = ctx.createLinearGradient(drip.x, drip.startY, drip.x, drip.startY + drip.length);
|
|
669
|
-
grad.addColorStop(0, `rgba(${inkRgb.r}, ${inkRgb.g}, ${inkRgb.b}, ${drip.startOpacity})`);
|
|
670
|
-
grad.addColorStop(1, `rgba(${inkRgb.r}, ${inkRgb.g}, ${inkRgb.b}, 0)`);
|
|
671
|
-
ctx.strokeStyle = grad;
|
|
672
|
-
ctx.lineWidth = drip.startWidth;
|
|
673
|
-
ctx.beginPath();
|
|
674
|
-
ctx.moveTo(drip.x, drip.startY);
|
|
675
|
-
ctx.lineTo(drip.x, drip.startY + drip.length);
|
|
676
|
-
ctx.stroke();
|
|
677
|
-
if (drip.hasBlob) {
|
|
678
|
-
ctx.fillStyle = `rgba(${inkRgb.r}, ${inkRgb.g}, ${inkRgb.b}, ${drip.startOpacity * 0.5})`;
|
|
679
|
-
ctx.beginPath();
|
|
680
|
-
ctx.arc(drip.x, drip.startY + drip.length, drip.blobRadius, 0, Math.PI * 2);
|
|
681
|
-
ctx.fill();
|
|
682
|
-
}
|
|
683
|
-
});
|
|
684
|
-
ctx.restore();
|
|
685
|
-
}
|
|
686
|
-
};
|
|
687
|
-
|
|
688
341
|
// src/canvas-utils.ts
|
|
689
342
|
function drawRoundedRect(ctx, x, y, w, h, r) {
|
|
690
343
|
const radius = Math.max(0, Math.min(r, Math.min(w, h) / 2));
|
|
@@ -704,8 +357,20 @@ function drawRoundedRect(ctx, x, y, w, h, r) {
|
|
|
704
357
|
}
|
|
705
358
|
}
|
|
706
359
|
|
|
360
|
+
// src/engine/procedural/utils.ts
|
|
361
|
+
function hexToRgb(hex) {
|
|
362
|
+
const shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
|
|
363
|
+
const fullHex = hex.replace(shorthandRegex, (m, r, g, b) => r + r + g + g + b + b);
|
|
364
|
+
const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(fullHex);
|
|
365
|
+
return result ? {
|
|
366
|
+
r: parseInt(result[1], 16),
|
|
367
|
+
g: parseInt(result[2], 16),
|
|
368
|
+
b: parseInt(result[3], 16)
|
|
369
|
+
} : { r: 255, g: 255, b: 255 };
|
|
370
|
+
}
|
|
371
|
+
|
|
707
372
|
// src/renderer.ts
|
|
708
|
-
function
|
|
373
|
+
function getCanvas2DContext(canvas) {
|
|
709
374
|
return canvas.getContext("2d");
|
|
710
375
|
}
|
|
711
376
|
function ctxSupportsFilter(ctx) {
|
|
@@ -720,11 +385,6 @@ function ctxSupportsFilter(ctx) {
|
|
|
720
385
|
}
|
|
721
386
|
}
|
|
722
387
|
function renderTextEffectCore(ctx, cfg) {
|
|
723
|
-
if (cfg.customRenderer === "InkBrushEngine") {
|
|
724
|
-
const engine = new InkBrushEngine(cfg);
|
|
725
|
-
engine.drawFrame(ctx);
|
|
726
|
-
return;
|
|
727
|
-
}
|
|
728
388
|
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;
|
|
729
389
|
ctx.imageSmoothingEnabled = true;
|
|
730
390
|
ctx.lineJoin = strokeLineJoin;
|
|
@@ -910,6 +570,68 @@ function renderTextEffectCore(ctx, cfg) {
|
|
|
910
570
|
}
|
|
911
571
|
ctx.restore();
|
|
912
572
|
};
|
|
573
|
+
const renderGlowLayer = (layer2) => {
|
|
574
|
+
let glowCanvas = null;
|
|
575
|
+
try {
|
|
576
|
+
glowCanvas = createCanvas(Math.max(1, Math.ceil(cWidth)), Math.max(1, Math.ceil(cHeight)));
|
|
577
|
+
const glowCtx = getCanvas2DContext(glowCanvas);
|
|
578
|
+
if (!glowCtx) return false;
|
|
579
|
+
glowCtx.clearRect(0, 0, cWidth, cHeight);
|
|
580
|
+
glowCtx.save();
|
|
581
|
+
glowCtx.font = fontStr;
|
|
582
|
+
glowCtx.textAlign = align;
|
|
583
|
+
glowCtx.textBaseline = "alphabetic";
|
|
584
|
+
if (letterSpacing !== 0) glowCtx.letterSpacing = `${letterSpacing}px`;
|
|
585
|
+
glowCtx.globalAlpha = Math.max(0, Math.min(100, layer2.opacity)) / 100;
|
|
586
|
+
glowCtx.fillStyle = layer2.color;
|
|
587
|
+
glowCtx.strokeStyle = layer2.color;
|
|
588
|
+
const spread = Math.max(0, layer2.spread ?? 0);
|
|
589
|
+
if (spread > 0) {
|
|
590
|
+
glowCtx.lineWidth = spread * 2;
|
|
591
|
+
glowCtx.lineJoin = strokeLineJoin;
|
|
592
|
+
}
|
|
593
|
+
const drawSource = () => {
|
|
594
|
+
lines.forEach((line, index) => {
|
|
595
|
+
const py = startY + index * lineAdvance;
|
|
596
|
+
if (spread > 0) glowCtx.strokeText(line, startX, py);
|
|
597
|
+
glowCtx.fillText(line, startX, py);
|
|
598
|
+
});
|
|
599
|
+
};
|
|
600
|
+
const useFilter = ctxSupportsFilter(glowCtx);
|
|
601
|
+
if (useFilter) {
|
|
602
|
+
glowCtx.filter = `blur(${Math.max(0, layer2.blur)}px)`;
|
|
603
|
+
drawSource();
|
|
604
|
+
glowCtx.filter = "none";
|
|
605
|
+
} else {
|
|
606
|
+
glowCtx.shadowColor = layer2.color;
|
|
607
|
+
glowCtx.shadowBlur = Math.max(0, layer2.blur);
|
|
608
|
+
glowCtx.shadowOffsetX = 0;
|
|
609
|
+
glowCtx.shadowOffsetY = 0;
|
|
610
|
+
drawSource();
|
|
611
|
+
glowCtx.shadowColor = "transparent";
|
|
612
|
+
glowCtx.shadowBlur = 0;
|
|
613
|
+
}
|
|
614
|
+
glowCtx.globalCompositeOperation = "destination-out";
|
|
615
|
+
glowCtx.globalAlpha = 1;
|
|
616
|
+
drawSource();
|
|
617
|
+
glowCtx.restore();
|
|
618
|
+
ctx.save();
|
|
619
|
+
if (layer2.type === "inner") {
|
|
620
|
+
ctx.globalCompositeOperation = "source-atop";
|
|
621
|
+
}
|
|
622
|
+
ctx.globalAlpha = 1;
|
|
623
|
+
const passes = Math.max(1, Math.min(20, layer2.strength ?? 1));
|
|
624
|
+
for (let pass = 0; pass < passes; pass += 1) {
|
|
625
|
+
ctx.drawImage(glowCanvas, 0, 0);
|
|
626
|
+
}
|
|
627
|
+
ctx.restore();
|
|
628
|
+
return true;
|
|
629
|
+
} catch {
|
|
630
|
+
return false;
|
|
631
|
+
} finally {
|
|
632
|
+
if (glowCanvas) releaseCanvas(glowCanvas);
|
|
633
|
+
}
|
|
634
|
+
};
|
|
913
635
|
if (panelEnabled) {
|
|
914
636
|
ctx.save();
|
|
915
637
|
ctx.globalAlpha = panelOpacity / 100;
|
|
@@ -959,9 +681,11 @@ function renderTextEffectCore(ctx, cfg) {
|
|
|
959
681
|
}
|
|
960
682
|
glowLayers.forEach((layer2) => {
|
|
961
683
|
if (layer2.enabled && layer2.type === "outer" && layer2.opacity > 0) {
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
684
|
+
if (!renderGlowLayer(layer2)) {
|
|
685
|
+
const renderCount = Math.max(1, Math.min(20, layer2.strength ?? 1));
|
|
686
|
+
for (let i = 0; i < renderCount; i += 1) {
|
|
687
|
+
renderWithShadowTrick("fill", layer2.color, layer2.blur, 0, 0, layer2.opacity, "#000", layer2.spread ?? 0);
|
|
688
|
+
}
|
|
965
689
|
}
|
|
966
690
|
}
|
|
967
691
|
});
|
|
@@ -1319,7 +1043,7 @@ function renderTextEffectCore(ctx, cfg) {
|
|
|
1319
1043
|
patCanvas.width = 120;
|
|
1320
1044
|
patCanvas.height = 120;
|
|
1321
1045
|
}
|
|
1322
|
-
const patCtx =
|
|
1046
|
+
const patCtx = getCanvas2DContext(patCanvas);
|
|
1323
1047
|
const seedRandom = (initSeed) => {
|
|
1324
1048
|
let currentSeed = initSeed;
|
|
1325
1049
|
return () => {
|
|
@@ -1733,7 +1457,7 @@ function renderTextEffectCore(ctx, cfg) {
|
|
|
1733
1457
|
const tCanvas = createCanvas(cWidth, cHeight);
|
|
1734
1458
|
tCanvas.width = cWidth;
|
|
1735
1459
|
tCanvas.height = cHeight;
|
|
1736
|
-
const tCtx =
|
|
1460
|
+
const tCtx = getCanvas2DContext(tCanvas);
|
|
1737
1461
|
if (tCtx) {
|
|
1738
1462
|
tCtx.font = fontStr;
|
|
1739
1463
|
tCtx.textAlign = align;
|
|
@@ -1862,7 +1586,7 @@ function renderTextEffectCore(ctx, cfg) {
|
|
|
1862
1586
|
const tintCanvas = createCanvas(cWidth, cHeight);
|
|
1863
1587
|
tintCanvas.width = cWidth;
|
|
1864
1588
|
tintCanvas.height = cHeight;
|
|
1865
|
-
const tintCtx =
|
|
1589
|
+
const tintCtx = getCanvas2DContext(tintCanvas);
|
|
1866
1590
|
if (tintCtx) {
|
|
1867
1591
|
tintCtx.drawImage(tCanvas, 0, 0);
|
|
1868
1592
|
tintCtx.globalCompositeOperation = "source-in";
|
|
@@ -1889,10 +1613,12 @@ function renderTextEffectCore(ctx, cfg) {
|
|
|
1889
1613
|
glowLayers.forEach((layer2) => {
|
|
1890
1614
|
if (layer2.enabled && layer2.type === "inner" && layer2.opacity > 0) {
|
|
1891
1615
|
ctx.save();
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1616
|
+
if (!renderGlowLayer(layer2)) {
|
|
1617
|
+
ctx.globalCompositeOperation = "source-atop";
|
|
1618
|
+
const renderCount = Math.max(1, Math.min(20, layer2.strength ?? 1));
|
|
1619
|
+
for (let i = 0; i < renderCount; i += 1) {
|
|
1620
|
+
renderWithShadowTrick("fill", layer2.color, layer2.blur, 0, 0, layer2.opacity, "#000000", layer2.spread ?? 0);
|
|
1621
|
+
}
|
|
1896
1622
|
}
|
|
1897
1623
|
ctx.restore();
|
|
1898
1624
|
}
|
|
@@ -1990,245 +1716,9 @@ var defaultConfig = {
|
|
|
1990
1716
|
textPosX: "center",
|
|
1991
1717
|
textPosY: "middle",
|
|
1992
1718
|
wrapText: true,
|
|
1993
|
-
autoFitText: false
|
|
1994
|
-
// Ink Brush custom properties
|
|
1995
|
-
inkColor: "#FFFFFF",
|
|
1996
|
-
bristleDensity: 0.8,
|
|
1997
|
-
bristleSkipRate: 0.2,
|
|
1998
|
-
dripRate: 0.3,
|
|
1999
|
-
dripMaxLength: 40,
|
|
2000
|
-
grainDensity: 0.15,
|
|
2001
|
-
skewX: -0.2
|
|
1719
|
+
autoFitText: false
|
|
2002
1720
|
};
|
|
2003
|
-
var builtInPresets = [
|
|
2004
|
-
{
|
|
2005
|
-
id: "premium-sticker",
|
|
2006
|
-
name: "STICKER",
|
|
2007
|
-
category: "Classic",
|
|
2008
|
-
config: {
|
|
2009
|
-
...defaultConfig,
|
|
2010
|
-
text: "TEXT",
|
|
2011
|
-
effectName: "StickerEffect",
|
|
2012
|
-
fontFamily: "Arial Rounded MT Bold",
|
|
2013
|
-
fontWeight: 900,
|
|
2014
|
-
fontStyle: "normal",
|
|
2015
|
-
fontSize: 88,
|
|
2016
|
-
letterSpacing: 2,
|
|
2017
|
-
lineHeight: 1.2,
|
|
2018
|
-
fillType: "linear",
|
|
2019
|
-
fillGradientAngle: 90,
|
|
2020
|
-
fillGradientStops: [
|
|
2021
|
-
{ color: "#FFCE00", offset: 0 },
|
|
2022
|
-
{ color: "#E05300", offset: 100 }
|
|
2023
|
-
],
|
|
2024
|
-
strokeEnabled: true,
|
|
2025
|
-
strokeColor: "#FFFFFF",
|
|
2026
|
-
strokeWidth: 15,
|
|
2027
|
-
strokePosition: "outside",
|
|
2028
|
-
strokeType: "single",
|
|
2029
|
-
strokeLineJoin: "round",
|
|
2030
|
-
strokeOpacity: 100,
|
|
2031
|
-
bevelEnabled: true,
|
|
2032
|
-
bevelDepth: 8,
|
|
2033
|
-
bevelDirection: "bottom-right",
|
|
2034
|
-
bevelHighlight: "#FFCE00",
|
|
2035
|
-
bevelCoreColor: "#4E1901",
|
|
2036
|
-
bevelShadow: "#1D0A00",
|
|
2037
|
-
shadowEnabled: true,
|
|
2038
|
-
shadowColor: "#000000",
|
|
2039
|
-
shadowBlur: 14,
|
|
2040
|
-
shadowOffsetX: 6,
|
|
2041
|
-
shadowOffsetY: 8,
|
|
2042
|
-
shadowOpacity: 65,
|
|
2043
|
-
shadowType: "drop"
|
|
2044
|
-
}
|
|
2045
|
-
},
|
|
2046
|
-
{
|
|
2047
|
-
id: "premium-holo",
|
|
2048
|
-
name: "HOLOGRAPHIC",
|
|
2049
|
-
category: "Classic",
|
|
2050
|
-
config: {
|
|
2051
|
-
...defaultConfig,
|
|
2052
|
-
text: "TEXT",
|
|
2053
|
-
effectName: "HolographicEffect",
|
|
2054
|
-
fontFamily: "Impact",
|
|
2055
|
-
fontWeight: 900,
|
|
2056
|
-
fontStyle: "normal",
|
|
2057
|
-
fontSize: 100,
|
|
2058
|
-
letterSpacing: 2,
|
|
2059
|
-
lineHeight: 1.2,
|
|
2060
|
-
fillType: "linear",
|
|
2061
|
-
fillGradientAngle: 125,
|
|
2062
|
-
fillGradientStops: [
|
|
2063
|
-
{ color: "#6FE3FF", offset: 0 },
|
|
2064
|
-
{ color: "#D196FF", offset: 25 },
|
|
2065
|
-
{ color: "#FF9CEE", offset: 50 },
|
|
2066
|
-
{ color: "#FFE49E", offset: 75 },
|
|
2067
|
-
{ color: "#D4FFF1", offset: 100 }
|
|
2068
|
-
],
|
|
2069
|
-
strokeEnabled: true,
|
|
2070
|
-
strokeColor: "#FFFFFF",
|
|
2071
|
-
strokeWidth: 2,
|
|
2072
|
-
strokePosition: "outside",
|
|
2073
|
-
strokeType: "single",
|
|
2074
|
-
strokeOpacity: 100,
|
|
2075
|
-
glowLayers: [{ enabled: true, color: "#D196FF", blur: 15, opacity: 50, type: "outer" }],
|
|
2076
|
-
bevelEnabled: true,
|
|
2077
|
-
bevelDepth: 4,
|
|
2078
|
-
bevelDirection: "bottom-right",
|
|
2079
|
-
bevelHighlight: "#FFFFFF",
|
|
2080
|
-
bevelCoreColor: "#2A3540",
|
|
2081
|
-
bevelShadow: "#0E151D",
|
|
2082
|
-
shadowEnabled: true,
|
|
2083
|
-
shadowColor: "#000000",
|
|
2084
|
-
shadowBlur: 20,
|
|
2085
|
-
shadowOffsetX: 6,
|
|
2086
|
-
shadowOffsetY: 10,
|
|
2087
|
-
shadowOpacity: 90,
|
|
2088
|
-
shadowType: "drop"
|
|
2089
|
-
}
|
|
2090
|
-
},
|
|
2091
|
-
{
|
|
2092
|
-
id: "classic-ink",
|
|
2093
|
-
name: "Classic Ink",
|
|
2094
|
-
category: "Classic",
|
|
2095
|
-
config: {
|
|
2096
|
-
...defaultConfig,
|
|
2097
|
-
text: "Classic Ink",
|
|
2098
|
-
effectName: "ClassicInk",
|
|
2099
|
-
fontFamily: "Playfair Display",
|
|
2100
|
-
fontWeight: 700,
|
|
2101
|
-
fontStyle: "normal",
|
|
2102
|
-
fontSize: 85,
|
|
2103
|
-
letterSpacing: 1,
|
|
2104
|
-
lineHeight: 1.2,
|
|
2105
|
-
fillType: "linear",
|
|
2106
|
-
fillGradientAngle: 90,
|
|
2107
|
-
fillGradientStops: [
|
|
2108
|
-
{ color: "#FDFBF7", offset: 0 },
|
|
2109
|
-
{ color: "#EAE5D9", offset: 100 }
|
|
2110
|
-
],
|
|
2111
|
-
strokeEnabled: true,
|
|
2112
|
-
strokeColor: "#1E1E26",
|
|
2113
|
-
strokeWidth: 2,
|
|
2114
|
-
strokePosition: "outside",
|
|
2115
|
-
strokeOpacity: 100,
|
|
2116
|
-
strokeLineJoin: "round",
|
|
2117
|
-
shadowEnabled: true,
|
|
2118
|
-
shadowColor: "#3D2B1F",
|
|
2119
|
-
shadowBlur: 14,
|
|
2120
|
-
shadowOffsetX: 6,
|
|
2121
|
-
shadowOffsetY: 6,
|
|
2122
|
-
shadowOpacity: 90,
|
|
2123
|
-
shadowType: "drop"
|
|
2124
|
-
}
|
|
2125
|
-
},
|
|
2126
|
-
{
|
|
2127
|
-
id: "neon-crimson",
|
|
2128
|
-
name: "Neon Crimson",
|
|
2129
|
-
category: "Neon",
|
|
2130
|
-
config: {
|
|
2131
|
-
...defaultConfig,
|
|
2132
|
-
text: "NEON",
|
|
2133
|
-
effectName: "NeonCrimson",
|
|
2134
|
-
fontFamily: "Bebas Neue",
|
|
2135
|
-
fontWeight: 700,
|
|
2136
|
-
fontStyle: "normal",
|
|
2137
|
-
fontSize: 100,
|
|
2138
|
-
letterSpacing: 6,
|
|
2139
|
-
lineHeight: 1.2,
|
|
2140
|
-
fillType: "none",
|
|
2141
|
-
strokeEnabled: true,
|
|
2142
|
-
strokeColor: "#FFFFFF",
|
|
2143
|
-
strokeWidth: 3,
|
|
2144
|
-
strokePosition: "center",
|
|
2145
|
-
strokeOpacity: 100,
|
|
2146
|
-
strokeLineJoin: "round",
|
|
2147
|
-
glowLayers: [
|
|
2148
|
-
{ enabled: true, color: "#FF003C", blur: 12, opacity: 100, type: "outer" },
|
|
2149
|
-
{ enabled: true, color: "#FF003C", blur: 35, opacity: 80, type: "outer" },
|
|
2150
|
-
{ enabled: true, color: "#FF003C", blur: 80, opacity: 60, type: "outer" }
|
|
2151
|
-
],
|
|
2152
|
-
shadowEnabled: false
|
|
2153
|
-
}
|
|
2154
|
-
},
|
|
2155
|
-
{
|
|
2156
|
-
id: "cyberpunk-yellow",
|
|
2157
|
-
name: "Cyberpunk Yellow",
|
|
2158
|
-
category: "Neon",
|
|
2159
|
-
config: {
|
|
2160
|
-
...defaultConfig,
|
|
2161
|
-
text: "CYBER",
|
|
2162
|
-
effectName: "CyberpunkYellow",
|
|
2163
|
-
fontFamily: "Anton",
|
|
2164
|
-
fontWeight: 900,
|
|
2165
|
-
fontStyle: "normal",
|
|
2166
|
-
fontSize: 90,
|
|
2167
|
-
letterSpacing: 2,
|
|
2168
|
-
lineHeight: 1.2,
|
|
2169
|
-
fillType: "solid",
|
|
2170
|
-
fillColor: "#FFE600",
|
|
2171
|
-
strokeEnabled: true,
|
|
2172
|
-
strokeColor: "#000000",
|
|
2173
|
-
strokeWidth: 6,
|
|
2174
|
-
strokePosition: "outside",
|
|
2175
|
-
strokeOpacity: 100,
|
|
2176
|
-
strokeLineJoin: "round",
|
|
2177
|
-
shadowEnabled: true,
|
|
2178
|
-
shadowColor: "#FFE600",
|
|
2179
|
-
shadowBlur: 15,
|
|
2180
|
-
shadowOffsetX: 4,
|
|
2181
|
-
shadowOffsetY: 4,
|
|
2182
|
-
shadowOpacity: 95,
|
|
2183
|
-
shadowType: "drop"
|
|
2184
|
-
}
|
|
2185
|
-
},
|
|
2186
|
-
{
|
|
2187
|
-
id: "retro-comic",
|
|
2188
|
-
name: "Retro Comic",
|
|
2189
|
-
category: "Experimental",
|
|
2190
|
-
config: {
|
|
2191
|
-
...defaultConfig,
|
|
2192
|
-
text: "BOOM!",
|
|
2193
|
-
effectName: "RetroComic",
|
|
2194
|
-
fontFamily: "Arial Black",
|
|
2195
|
-
fontWeight: 900,
|
|
2196
|
-
fontStyle: "normal",
|
|
2197
|
-
fontSize: 85,
|
|
2198
|
-
letterSpacing: 3,
|
|
2199
|
-
lineHeight: 1.1,
|
|
2200
|
-
fillType: "solid",
|
|
2201
|
-
fillColor: "#000000",
|
|
2202
|
-
strokeEnabled: true,
|
|
2203
|
-
strokeColor: "#FFFFFF",
|
|
2204
|
-
strokeWidth: 6,
|
|
2205
|
-
strokePosition: "outside",
|
|
2206
|
-
strokeOpacity: 100,
|
|
2207
|
-
strokeLineJoin: "round",
|
|
2208
|
-
glowLayers: [
|
|
2209
|
-
{ enabled: true, color: "#000000", blur: 0, opacity: 100, type: "outer", strength: 1, spread: 3 },
|
|
2210
|
-
{ enabled: false, color: "#FF007C", blur: 40, opacity: 60, type: "outer" },
|
|
2211
|
-
{ enabled: false, color: "#00F0FF", blur: 60, opacity: 40, type: "outer" }
|
|
2212
|
-
],
|
|
2213
|
-
// panelEnabled: true,
|
|
2214
|
-
// panelColor: "#FFE100",
|
|
2215
|
-
// panelOpacity: 100,
|
|
2216
|
-
// panelRadius: 10,
|
|
2217
|
-
// panelPaddingX: 55,
|
|
2218
|
-
// panelPaddingY: 35,
|
|
2219
|
-
// panelStrokeEnabled: true,
|
|
2220
|
-
// panelStrokeColor: "#000000",
|
|
2221
|
-
// panelStrokeWidth: 4,
|
|
2222
|
-
shadowEnabled: true,
|
|
2223
|
-
shadowColor: "#000000",
|
|
2224
|
-
shadowBlur: 0,
|
|
2225
|
-
shadowOffsetX: 8,
|
|
2226
|
-
shadowOffsetY: 8,
|
|
2227
|
-
shadowOpacity: 100,
|
|
2228
|
-
shadowType: "drop"
|
|
2229
|
-
}
|
|
2230
|
-
}
|
|
2231
|
-
];
|
|
1721
|
+
var builtInPresets = [];
|
|
2232
1722
|
|
|
2233
1723
|
// src/engine/timelineDefaults.ts
|
|
2234
1724
|
function ensureDefaultTimeline(doc) {
|
|
@@ -2276,7 +1766,7 @@ function ensureDefaultTimeline(doc) {
|
|
|
2276
1766
|
// src/engine/migrate.ts
|
|
2277
1767
|
function layer(type, name, params, extra) {
|
|
2278
1768
|
return {
|
|
2279
|
-
id: newLayerId(),
|
|
1769
|
+
id: extra?.id ?? newLayerId(),
|
|
2280
1770
|
type,
|
|
2281
1771
|
name,
|
|
2282
1772
|
enabled: true,
|
|
@@ -2287,72 +1777,61 @@ function layer(type, name, params, extra) {
|
|
|
2287
1777
|
...extra
|
|
2288
1778
|
};
|
|
2289
1779
|
}
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
1780
|
+
var REMOVED_INK_FIELDS = [
|
|
1781
|
+
"customRenderer",
|
|
1782
|
+
"inkColor",
|
|
1783
|
+
"bristleDensity",
|
|
1784
|
+
"bristleSkipRate",
|
|
1785
|
+
"dripRate",
|
|
1786
|
+
"dripMaxLength",
|
|
1787
|
+
"grainDensity",
|
|
1788
|
+
"skewX"
|
|
1789
|
+
];
|
|
1790
|
+
function stripRemovedRendererFields(value) {
|
|
1791
|
+
const out = { ...value };
|
|
1792
|
+
for (const key of REMOVED_INK_FIELDS) delete out[key];
|
|
1793
|
+
return out;
|
|
2293
1794
|
}
|
|
2294
1795
|
function textEffectConfigToScene(cfg) {
|
|
2295
|
-
const
|
|
1796
|
+
const safeConfig = stripRemovedRendererFields(cfg);
|
|
2296
1797
|
const layers = [];
|
|
2297
|
-
if (engineId) {
|
|
2298
|
-
layers.push(
|
|
2299
|
-
layer(
|
|
2300
|
-
"customEngine",
|
|
2301
|
-
"Custom Engine",
|
|
2302
|
-
{ engineId },
|
|
2303
|
-
{
|
|
2304
|
-
enabled: true,
|
|
2305
|
-
target: "scene"
|
|
2306
|
-
}
|
|
2307
|
-
)
|
|
2308
|
-
);
|
|
2309
|
-
layers.push(
|
|
2310
|
-
layer(
|
|
2311
|
-
"customEngine",
|
|
2312
|
-
"Engine Params",
|
|
2313
|
-
{ ...collectEngineParams(cfg, engineId) },
|
|
2314
|
-
{
|
|
2315
|
-
enabled: true,
|
|
2316
|
-
target: "text"
|
|
2317
|
-
}
|
|
2318
|
-
)
|
|
2319
|
-
);
|
|
2320
|
-
}
|
|
2321
1798
|
layers.push(
|
|
2322
1799
|
layer(
|
|
2323
1800
|
"panel",
|
|
2324
1801
|
"Background Panel",
|
|
2325
1802
|
{
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
1803
|
+
enabled: safeConfig.panelEnabled,
|
|
1804
|
+
panelEnabled: safeConfig.panelEnabled,
|
|
1805
|
+
panelColor: safeConfig.panelColor,
|
|
1806
|
+
panelOpacity: safeConfig.panelOpacity,
|
|
1807
|
+
panelRadius: safeConfig.panelRadius,
|
|
1808
|
+
panelPaddingX: safeConfig.panelPaddingX,
|
|
1809
|
+
panelPaddingY: safeConfig.panelPaddingY,
|
|
1810
|
+
panelStrokeEnabled: safeConfig.panelStrokeEnabled,
|
|
1811
|
+
panelStrokeColor: safeConfig.panelStrokeColor,
|
|
1812
|
+
panelStrokeWidth: safeConfig.panelStrokeWidth
|
|
2335
1813
|
},
|
|
2336
|
-
{ enabled:
|
|
1814
|
+
{ enabled: safeConfig.panelEnabled, id: "panel" }
|
|
2337
1815
|
)
|
|
2338
1816
|
);
|
|
2339
|
-
(
|
|
2340
|
-
layers.push(layer("glow", `Glow ${i + 1}`, { ...g }, { enabled: g.enabled, opacity: (g.opacity ?? 100) / 100 }));
|
|
1817
|
+
(safeConfig.glowLayers || []).forEach((g, i) => {
|
|
1818
|
+
layers.push(layer("glow", `Glow ${i + 1}`, { ...g, enabled: g.enabled }, { id: `glow-${i + 1}`, enabled: g.enabled, opacity: (g.opacity ?? 100) / 100 }));
|
|
2341
1819
|
});
|
|
2342
1820
|
layers.push(
|
|
2343
1821
|
layer(
|
|
2344
1822
|
"shadow",
|
|
2345
1823
|
"Shadow",
|
|
2346
1824
|
{
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
1825
|
+
enabled: safeConfig.shadowEnabled,
|
|
1826
|
+
shadowEnabled: safeConfig.shadowEnabled,
|
|
1827
|
+
shadowColor: safeConfig.shadowColor,
|
|
1828
|
+
shadowBlur: safeConfig.shadowBlur,
|
|
1829
|
+
shadowOffsetX: safeConfig.shadowOffsetX,
|
|
1830
|
+
shadowOffsetY: safeConfig.shadowOffsetY,
|
|
1831
|
+
shadowOpacity: safeConfig.shadowOpacity,
|
|
1832
|
+
shadowType: safeConfig.shadowType
|
|
2354
1833
|
},
|
|
2355
|
-
{ enabled:
|
|
1834
|
+
{ enabled: safeConfig.shadowEnabled, id: "shadow" }
|
|
2356
1835
|
)
|
|
2357
1836
|
);
|
|
2358
1837
|
layers.push(
|
|
@@ -2360,22 +1839,23 @@ function textEffectConfigToScene(cfg) {
|
|
|
2360
1839
|
"extrusion",
|
|
2361
1840
|
"Bevel / Extrusion",
|
|
2362
1841
|
{
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
1842
|
+
enabled: safeConfig.bevelEnabled,
|
|
1843
|
+
bevelEnabled: safeConfig.bevelEnabled,
|
|
1844
|
+
bevelDepth: safeConfig.bevelDepth,
|
|
1845
|
+
bevelHighlight: safeConfig.bevelHighlight,
|
|
1846
|
+
bevelShadow: safeConfig.bevelShadow,
|
|
1847
|
+
bevelDirection: safeConfig.bevelDirection,
|
|
1848
|
+
bevelCoreColor: safeConfig.bevelCoreColor,
|
|
1849
|
+
bevelEdgeColor: safeConfig.bevelEdgeColor,
|
|
1850
|
+
bevelEdgeWidth: safeConfig.bevelEdgeWidth,
|
|
1851
|
+
bevelBlur: safeConfig.bevelBlur,
|
|
1852
|
+
bevelBlurColor: safeConfig.bevelBlurColor,
|
|
1853
|
+
bevelPerspectiveEnabled: safeConfig.bevelPerspectiveEnabled,
|
|
1854
|
+
bevelVanishingPointX: safeConfig.bevelVanishingPointX,
|
|
1855
|
+
bevelVanishingPointY: safeConfig.bevelVanishingPointY,
|
|
1856
|
+
bevelFocalLength: safeConfig.bevelFocalLength
|
|
2377
1857
|
},
|
|
2378
|
-
{ enabled:
|
|
1858
|
+
{ enabled: safeConfig.bevelEnabled, id: "extrusion" }
|
|
2379
1859
|
)
|
|
2380
1860
|
);
|
|
2381
1861
|
layers.push(
|
|
@@ -2383,17 +1863,18 @@ function textEffectConfigToScene(cfg) {
|
|
|
2383
1863
|
"duplicateStack",
|
|
2384
1864
|
"Stack Extrusion",
|
|
2385
1865
|
{
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
1866
|
+
enabled: !!safeConfig.stackEnabled,
|
|
1867
|
+
stackEnabled: safeConfig.stackEnabled,
|
|
1868
|
+
stackCount: safeConfig.stackCount,
|
|
1869
|
+
stackOffsetX: safeConfig.stackOffsetX,
|
|
1870
|
+
stackOffsetY: safeConfig.stackOffsetY,
|
|
1871
|
+
stackOpacityDecay: safeConfig.stackOpacityDecay,
|
|
1872
|
+
stackColor1: safeConfig.stackColor1,
|
|
1873
|
+
stackColor2: safeConfig.stackColor2,
|
|
1874
|
+
stackColor3: safeConfig.stackColor3,
|
|
1875
|
+
stackColor4: safeConfig.stackColor4
|
|
2395
1876
|
},
|
|
2396
|
-
{ enabled: !!
|
|
1877
|
+
{ enabled: !!safeConfig.stackEnabled, id: "duplicate-stack" }
|
|
2397
1878
|
)
|
|
2398
1879
|
);
|
|
2399
1880
|
layers.push(
|
|
@@ -2401,19 +1882,20 @@ function textEffectConfigToScene(cfg) {
|
|
|
2401
1882
|
"stroke",
|
|
2402
1883
|
"Stroke",
|
|
2403
1884
|
{
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
1885
|
+
enabled: safeConfig.strokeEnabled,
|
|
1886
|
+
strokeEnabled: safeConfig.strokeEnabled,
|
|
1887
|
+
strokeColor: safeConfig.strokeColor,
|
|
1888
|
+
strokeWidth: safeConfig.strokeWidth,
|
|
1889
|
+
strokePosition: safeConfig.strokePosition,
|
|
1890
|
+
strokeOpacity: safeConfig.strokeOpacity,
|
|
1891
|
+
strokeLineJoin: safeConfig.strokeLineJoin,
|
|
1892
|
+
strokeBlur: safeConfig.strokeBlur,
|
|
1893
|
+
strokeType: safeConfig.strokeType,
|
|
1894
|
+
strokeColorSecondary: safeConfig.strokeColorSecondary,
|
|
1895
|
+
strokeWidthSecondary: safeConfig.strokeWidthSecondary,
|
|
1896
|
+
strokeFadeRange: safeConfig.strokeFadeRange
|
|
2415
1897
|
},
|
|
2416
|
-
{ enabled:
|
|
1898
|
+
{ enabled: safeConfig.strokeEnabled, id: "stroke" }
|
|
2417
1899
|
)
|
|
2418
1900
|
);
|
|
2419
1901
|
layers.push(
|
|
@@ -2421,73 +1903,57 @@ function textEffectConfigToScene(cfg) {
|
|
|
2421
1903
|
"fill",
|
|
2422
1904
|
"Fill",
|
|
2423
1905
|
{
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
1906
|
+
enabled: safeConfig.fillType !== "none",
|
|
1907
|
+
fillType: safeConfig.fillType,
|
|
1908
|
+
fillColor: safeConfig.fillColor,
|
|
1909
|
+
fillGradientAngle: safeConfig.fillGradientAngle,
|
|
1910
|
+
fillGradientStops: safeConfig.fillGradientStops,
|
|
1911
|
+
patternType: safeConfig.patternType,
|
|
1912
|
+
perCharFillEnabled: safeConfig.perCharFillEnabled,
|
|
1913
|
+
charFillColors: safeConfig.charFillColors
|
|
2431
1914
|
},
|
|
2432
|
-
{ enabled:
|
|
1915
|
+
{ enabled: safeConfig.fillType !== "none", id: "fill" }
|
|
2433
1916
|
)
|
|
2434
1917
|
);
|
|
2435
|
-
layers.push(layer("mask", "Text Alpha Mask", { maskType: "alphaText", revealProgress: 1 }, { enabled: false }));
|
|
2436
|
-
layers.push(layer("filter", "Compositor FX", { blur: 0, bloom: 0 }, { enabled: false, target: "previous" }));
|
|
1918
|
+
layers.push(layer("mask", "Text Alpha Mask", { maskType: "alphaText", revealProgress: 1 }, { enabled: false, id: "mask" }));
|
|
1919
|
+
layers.push(layer("filter", "Compositor FX", { blur: 0, bloom: 0 }, { enabled: false, target: "previous", id: "compositor" }));
|
|
2437
1920
|
const doc = {
|
|
2438
1921
|
version: 1,
|
|
2439
|
-
|
|
1922
|
+
schemaVersion: 2,
|
|
1923
|
+
effectName: safeConfig.effectName,
|
|
2440
1924
|
canvas: {
|
|
2441
|
-
width:
|
|
2442
|
-
height:
|
|
1925
|
+
width: safeConfig.canvasWidth,
|
|
1926
|
+
height: safeConfig.canvasHeight,
|
|
2443
1927
|
background: "transparent"
|
|
2444
1928
|
},
|
|
2445
1929
|
text: {
|
|
2446
|
-
content:
|
|
2447
|
-
fontFamily:
|
|
2448
|
-
fontWeight:
|
|
2449
|
-
fontStyle:
|
|
2450
|
-
fontSize:
|
|
2451
|
-
letterSpacing:
|
|
2452
|
-
lineHeight:
|
|
2453
|
-
textPosX:
|
|
2454
|
-
textPosY:
|
|
2455
|
-
wrapText:
|
|
2456
|
-
autoFitText: !!
|
|
2457
|
-
perCharFillEnabled:
|
|
2458
|
-
charFillColors:
|
|
1930
|
+
content: safeConfig.text,
|
|
1931
|
+
fontFamily: safeConfig.fontFamily,
|
|
1932
|
+
fontWeight: safeConfig.fontWeight,
|
|
1933
|
+
fontStyle: safeConfig.fontStyle,
|
|
1934
|
+
fontSize: safeConfig.fontSize,
|
|
1935
|
+
letterSpacing: safeConfig.letterSpacing,
|
|
1936
|
+
lineHeight: safeConfig.lineHeight,
|
|
1937
|
+
textPosX: safeConfig.textPosX,
|
|
1938
|
+
textPosY: safeConfig.textPosY,
|
|
1939
|
+
wrapText: safeConfig.wrapText !== false,
|
|
1940
|
+
autoFitText: !!safeConfig.autoFitText,
|
|
1941
|
+
perCharFillEnabled: safeConfig.perCharFillEnabled,
|
|
1942
|
+
charFillColors: safeConfig.charFillColors
|
|
2459
1943
|
},
|
|
2460
1944
|
effectLayers: layers,
|
|
2461
|
-
customEngineId: engineId,
|
|
2462
|
-
engineParams: engineId ? collectEngineParams(cfg, engineId) : void 0,
|
|
2463
1945
|
compositor: { blur: 0, bloom: 0, bloomThreshold: 0.6 },
|
|
2464
1946
|
timeline: { duration: 2, fps: 30, loop: true, tracks: [] },
|
|
2465
|
-
legacyConfig: { ...
|
|
1947
|
+
legacyConfig: { ...safeConfig }
|
|
2466
1948
|
};
|
|
2467
1949
|
return ensureDefaultTimeline(doc);
|
|
2468
1950
|
}
|
|
2469
|
-
function collectEngineParams(cfg, id) {
|
|
2470
|
-
switch (id) {
|
|
2471
|
-
case "ink":
|
|
2472
|
-
return {
|
|
2473
|
-
inkColor: cfg.inkColor,
|
|
2474
|
-
bristleDensity: cfg.bristleDensity,
|
|
2475
|
-
bristleSkipRate: cfg.bristleSkipRate,
|
|
2476
|
-
dripRate: cfg.dripRate,
|
|
2477
|
-
dripMaxLength: cfg.dripMaxLength,
|
|
2478
|
-
grainDensity: cfg.grainDensity,
|
|
2479
|
-
skewX: cfg.skewX
|
|
2480
|
-
};
|
|
2481
|
-
default:
|
|
2482
|
-
return {};
|
|
2483
|
-
}
|
|
2484
|
-
}
|
|
2485
1951
|
function getLayerParams(doc, type, index = 0) {
|
|
2486
1952
|
const found = doc.effectLayers.filter((l) => l.type === type);
|
|
2487
1953
|
return found[index]?.params;
|
|
2488
1954
|
}
|
|
2489
1955
|
function sceneToConfig(doc) {
|
|
2490
|
-
const base = doc.legacyConfig ?
|
|
1956
|
+
const base = doc.legacyConfig ? stripRemovedRendererFields(doc.legacyConfig) : {
|
|
2491
1957
|
...createDefaultFromScene(doc)
|
|
2492
1958
|
};
|
|
2493
1959
|
base.effectName = doc.effectName;
|
|
@@ -2504,11 +1970,15 @@ function sceneToConfig(doc) {
|
|
|
2504
1970
|
base.autoFitText = !!doc.text.autoFitText;
|
|
2505
1971
|
base.canvasWidth = doc.canvas.width;
|
|
2506
1972
|
base.canvasHeight = doc.canvas.height;
|
|
1973
|
+
const withoutLayerEnabled = (params) => {
|
|
1974
|
+
const { enabled: _enabled, ...visualParams } = params;
|
|
1975
|
+
return visualParams;
|
|
1976
|
+
};
|
|
2507
1977
|
const panel = getLayerParams(doc, "panel");
|
|
2508
1978
|
if (panel) {
|
|
2509
1979
|
Object.assign(base, {
|
|
2510
|
-
panelEnabled: panel.panelEnabled,
|
|
2511
|
-
|
|
1980
|
+
panelEnabled: !!doc.effectLayers.find((l) => l.type === "panel")?.enabled && panel.enabled !== false && panel.panelEnabled !== false,
|
|
1981
|
+
...withoutLayerEnabled(panel),
|
|
2512
1982
|
panelOpacity: panel.panelOpacity,
|
|
2513
1983
|
panelRadius: panel.panelRadius,
|
|
2514
1984
|
panelPaddingX: panel.panelPaddingX,
|
|
@@ -2522,7 +1992,7 @@ function sceneToConfig(doc) {
|
|
|
2522
1992
|
base.glowLayers = glows.map((l) => {
|
|
2523
1993
|
const p = l.params;
|
|
2524
1994
|
return {
|
|
2525
|
-
enabled: l.enabled && (p.enabled ?? true),
|
|
1995
|
+
enabled: l.enabled && (p.enabled ?? true) && (l.opacity ?? 1) > 0,
|
|
2526
1996
|
color: p.color ?? "#7C6FFF",
|
|
2527
1997
|
blur: p.blur ?? 20,
|
|
2528
1998
|
opacity: Math.round((p.opacity ?? 80) * (l.opacity ?? 1)),
|
|
@@ -2541,23 +2011,17 @@ function sceneToConfig(doc) {
|
|
|
2541
2011
|
});
|
|
2542
2012
|
}
|
|
2543
2013
|
const shadow = getLayerParams(doc, "shadow");
|
|
2544
|
-
if (shadow) Object.assign(base, shadow);
|
|
2014
|
+
if (shadow) Object.assign(base, { ...withoutLayerEnabled(shadow), shadowEnabled: !!doc.effectLayers.find((l) => l.type === "shadow")?.enabled && shadow.enabled !== false && shadow.shadowEnabled !== false });
|
|
2545
2015
|
const extrusion = getLayerParams(doc, "extrusion");
|
|
2546
|
-
if (extrusion) Object.assign(base, extrusion);
|
|
2016
|
+
if (extrusion) Object.assign(base, { ...withoutLayerEnabled(extrusion), bevelEnabled: !!doc.effectLayers.find((l) => l.type === "extrusion")?.enabled && extrusion.enabled !== false && extrusion.bevelEnabled !== false });
|
|
2547
2017
|
const stack = getLayerParams(doc, "duplicateStack");
|
|
2548
|
-
if (stack) Object.assign(base, stack);
|
|
2018
|
+
if (stack) Object.assign(base, { ...withoutLayerEnabled(stack), stackEnabled: !!doc.effectLayers.find((l) => l.type === "duplicateStack")?.enabled && stack.enabled !== false && stack.stackEnabled !== false });
|
|
2549
2019
|
const stroke = getLayerParams(doc, "stroke");
|
|
2550
|
-
if (stroke) Object.assign(base, stroke);
|
|
2020
|
+
if (stroke) Object.assign(base, { ...withoutLayerEnabled(stroke), strokeEnabled: !!doc.effectLayers.find((l) => l.type === "stroke")?.enabled && stroke.enabled !== false && stroke.strokeEnabled !== false });
|
|
2551
2021
|
const fill = getLayerParams(doc, "fill");
|
|
2552
|
-
if (fill) Object.assign(base, fill);
|
|
2022
|
+
if (fill) Object.assign(base, withoutLayerEnabled(fill));
|
|
2553
2023
|
base.perCharFillEnabled = doc.text.perCharFillEnabled ?? fill?.perCharFillEnabled;
|
|
2554
2024
|
base.charFillColors = doc.text.charFillColors ?? fill?.charFillColors;
|
|
2555
|
-
if (doc.customEngineId) {
|
|
2556
|
-
base.customRenderer = ENGINE_ID_TO_LEGACY[doc.customEngineId];
|
|
2557
|
-
Object.assign(base, doc.engineParams || {});
|
|
2558
|
-
} else {
|
|
2559
|
-
base.customRenderer = void 0;
|
|
2560
|
-
}
|
|
2561
2025
|
base.glowLayers = base.glowLayers.slice(0, 6);
|
|
2562
2026
|
const filterLayers = doc.effectLayers.filter((l) => l.type === "filter" && l.enabled);
|
|
2563
2027
|
const filter = filterLayers[filterLayers.length - 1]?.params;
|
|
@@ -2627,7 +2091,7 @@ function _buildConfig(effect, text, fontSize, canvasWidth, canvasHeight, time, c
|
|
|
2627
2091
|
if (effect.animation) {
|
|
2628
2092
|
config.animation = effect.animation;
|
|
2629
2093
|
}
|
|
2630
|
-
if (fill) {
|
|
2094
|
+
if (fill && fill.enabled !== false) {
|
|
2631
2095
|
if (fill.type !== void 0) config.fillType = fill.type;
|
|
2632
2096
|
if (fill.color !== void 0) config.fillColor = fill.color;
|
|
2633
2097
|
if (fill.gradient?.angle !== void 0) config.fillGradientAngle = fill.gradient.angle;
|
|
@@ -2638,7 +2102,7 @@ function _buildConfig(effect, text, fontSize, canvasWidth, canvasHeight, time, c
|
|
|
2638
2102
|
} else {
|
|
2639
2103
|
config.fillType = "none";
|
|
2640
2104
|
}
|
|
2641
|
-
config.strokeEnabled = !!stroke;
|
|
2105
|
+
config.strokeEnabled = !!stroke && stroke.enabled !== false;
|
|
2642
2106
|
if (stroke) {
|
|
2643
2107
|
if (stroke.color !== void 0) config.strokeColor = stroke.color;
|
|
2644
2108
|
if (stroke.width !== void 0) config.strokeWidth = stroke.width * ratio;
|
|
@@ -2651,7 +2115,7 @@ function _buildConfig(effect, text, fontSize, canvasWidth, canvasHeight, time, c
|
|
|
2651
2115
|
if (stroke.widthSecondary !== void 0) config.strokeWidthSecondary = stroke.widthSecondary * ratio;
|
|
2652
2116
|
if (stroke.fadeRange !== void 0) config.strokeFadeRange = stroke.fadeRange;
|
|
2653
2117
|
}
|
|
2654
|
-
config.shadowEnabled = !!shadow;
|
|
2118
|
+
config.shadowEnabled = !!shadow && shadow.enabled !== false;
|
|
2655
2119
|
if (shadow) {
|
|
2656
2120
|
if (shadow.color !== void 0) config.shadowColor = shadow.color;
|
|
2657
2121
|
if (shadow.blur !== void 0) config.shadowBlur = shadow.blur * ratio;
|
|
@@ -2662,7 +2126,7 @@ function _buildConfig(effect, text, fontSize, canvasWidth, canvasHeight, time, c
|
|
|
2662
2126
|
if (shadow.opacity !== void 0) config.shadowOpacity = shadow.opacity;
|
|
2663
2127
|
if (shadow.type !== void 0) config.shadowType = shadow.type;
|
|
2664
2128
|
}
|
|
2665
|
-
config.bevelEnabled = !!bevel;
|
|
2129
|
+
config.bevelEnabled = !!bevel && bevel.enabled !== false;
|
|
2666
2130
|
if (bevel) {
|
|
2667
2131
|
if (bevel.depth !== void 0) config.bevelDepth = Math.round(bevel.depth * ratio);
|
|
2668
2132
|
if (bevel.highlight !== void 0) config.bevelHighlight = bevel.highlight;
|
|
@@ -2681,17 +2145,19 @@ function _buildConfig(effect, text, fontSize, canvasWidth, canvasHeight, time, c
|
|
|
2681
2145
|
if (bevel.focalLength !== void 0) config.bevelFocalLength = bevel.focalLength;
|
|
2682
2146
|
}
|
|
2683
2147
|
if (effect.stack) {
|
|
2684
|
-
config.stackEnabled = !!effect.stack.count;
|
|
2148
|
+
config.stackEnabled = effect.stack.enabled !== false && !!effect.stack.count;
|
|
2685
2149
|
if (effect.stack.count !== void 0) config.stackCount = effect.stack.count;
|
|
2686
2150
|
if (effect.stack.offsetX !== void 0) config.stackOffsetX = effect.stack.offsetX * ratio;
|
|
2687
2151
|
if (effect.stack.offsetY !== void 0) config.stackOffsetY = effect.stack.offsetY * ratio;
|
|
2688
|
-
if (effect.stack.opacityDecay !== void 0)
|
|
2152
|
+
if (effect.stack.opacityDecay !== void 0) {
|
|
2153
|
+
config.stackOpacityDecay = effect.stack.opacityDecay <= 1 ? effect.stack.opacityDecay * 100 : effect.stack.opacityDecay;
|
|
2154
|
+
}
|
|
2689
2155
|
if (effect.stack.color1 !== void 0) config.stackColor1 = effect.stack.color1;
|
|
2690
2156
|
if (effect.stack.color2 !== void 0) config.stackColor2 = effect.stack.color2;
|
|
2691
2157
|
if (effect.stack.color3 !== void 0) config.stackColor3 = effect.stack.color3;
|
|
2692
2158
|
if (effect.stack.color4 !== void 0) config.stackColor4 = effect.stack.color4;
|
|
2693
2159
|
}
|
|
2694
|
-
config.panelEnabled = !!panel;
|
|
2160
|
+
config.panelEnabled = !!panel && panel.enabled !== false;
|
|
2695
2161
|
if (panel) {
|
|
2696
2162
|
if (panel.color !== void 0) config.panelColor = panel.color;
|
|
2697
2163
|
if (panel.opacity !== void 0) config.panelOpacity = panel.opacity;
|
|
@@ -2700,16 +2166,17 @@ function _buildConfig(effect, text, fontSize, canvasWidth, canvasHeight, time, c
|
|
|
2700
2166
|
else if (panel.paddingX !== void 0) config.panelPaddingX = panel.paddingX * ratio;
|
|
2701
2167
|
if (panel.padding?.y !== void 0) config.panelPaddingY = panel.padding.y * ratio;
|
|
2702
2168
|
else if (panel.paddingY !== void 0) config.panelPaddingY = panel.paddingY * ratio;
|
|
2703
|
-
if (panel.stroke
|
|
2704
|
-
config.panelStrokeEnabled =
|
|
2169
|
+
if (panel.stroke) {
|
|
2170
|
+
config.panelStrokeEnabled = panel.stroke.enabled !== false;
|
|
2705
2171
|
if (panel.stroke.color !== void 0) config.panelStrokeColor = panel.stroke.color;
|
|
2706
2172
|
if (panel.stroke.width !== void 0) config.panelStrokeWidth = panel.stroke.width * ratio;
|
|
2707
2173
|
}
|
|
2708
2174
|
}
|
|
2709
|
-
if (effect.glows) {
|
|
2710
|
-
|
|
2175
|
+
if (effect.glows || effect.glow) {
|
|
2176
|
+
const sourceGlows = effect.glows ?? [effect.glow];
|
|
2177
|
+
config.glowLayers = sourceGlows.map((g) => {
|
|
2711
2178
|
const mappedGlow = {
|
|
2712
|
-
enabled:
|
|
2179
|
+
enabled: g.enabled !== false,
|
|
2713
2180
|
color: g.color,
|
|
2714
2181
|
blur: typeof g.blur === "number" ? g.blur * ratio : g.blur ?? 0,
|
|
2715
2182
|
opacity: g.opacity,
|
|
@@ -2720,15 +2187,6 @@ function _buildConfig(effect, text, fontSize, canvasWidth, canvasHeight, time, c
|
|
|
2720
2187
|
return mappedGlow;
|
|
2721
2188
|
});
|
|
2722
2189
|
}
|
|
2723
|
-
const rawEffect = effect;
|
|
2724
|
-
if (rawEffect.customRenderer !== void 0) config.customRenderer = rawEffect.customRenderer;
|
|
2725
|
-
if (rawEffect.inkColor !== void 0) config.inkColor = rawEffect.inkColor;
|
|
2726
|
-
if (rawEffect.bristleDensity !== void 0) config.bristleDensity = rawEffect.bristleDensity;
|
|
2727
|
-
if (rawEffect.bristleSkipRate !== void 0) config.bristleSkipRate = rawEffect.bristleSkipRate;
|
|
2728
|
-
if (rawEffect.dripRate !== void 0) config.dripRate = rawEffect.dripRate;
|
|
2729
|
-
if (rawEffect.dripMaxLength !== void 0) config.dripMaxLength = rawEffect.dripMaxLength;
|
|
2730
|
-
if (rawEffect.grainDensity !== void 0) config.grainDensity = rawEffect.grainDensity;
|
|
2731
|
-
if (rawEffect.skewX !== void 0) config.skewX = rawEffect.skewX;
|
|
2732
2190
|
const standardKeys = /* @__PURE__ */ new Set([
|
|
2733
2191
|
"id",
|
|
2734
2192
|
"name",
|
|
@@ -2821,15 +2279,7 @@ function _buildConfig(effect, text, fontSize, canvasWidth, canvasHeight, time, c
|
|
|
2821
2279
|
"textPosX",
|
|
2822
2280
|
"textPosY",
|
|
2823
2281
|
"autoFitText",
|
|
2824
|
-
"wrapText"
|
|
2825
|
-
"customRenderer",
|
|
2826
|
-
"inkColor",
|
|
2827
|
-
"bristleDensity",
|
|
2828
|
-
"bristleSkipRate",
|
|
2829
|
-
"dripRate",
|
|
2830
|
-
"dripMaxLength",
|
|
2831
|
-
"grainDensity",
|
|
2832
|
-
"skewX"
|
|
2282
|
+
"wrapText"
|
|
2833
2283
|
]);
|
|
2834
2284
|
for (const key of Object.keys(effect)) {
|
|
2835
2285
|
if (!standardKeys.has(key)) {
|
|
@@ -2903,170 +2353,6 @@ function applyTimelineAtTime(doc, time) {
|
|
|
2903
2353
|
return { ...doc, effectLayers: layers };
|
|
2904
2354
|
}
|
|
2905
2355
|
|
|
2906
|
-
// src/compositor/index.ts
|
|
2907
|
-
var VERTEX_SRC = `#version 300 es
|
|
2908
|
-
in vec2 a_pos;
|
|
2909
|
-
in vec2 a_uv;
|
|
2910
|
-
out vec2 v_uv;
|
|
2911
|
-
void main() {
|
|
2912
|
-
v_uv = a_uv;
|
|
2913
|
-
gl_Position = vec4(a_pos, 0.0, 1.0);
|
|
2914
|
-
}
|
|
2915
|
-
`;
|
|
2916
|
-
var FRAGMENT_SRC = `#version 300 es
|
|
2917
|
-
precision highp float;
|
|
2918
|
-
in vec2 v_uv;
|
|
2919
|
-
uniform sampler2D u_tex;
|
|
2920
|
-
uniform vec2 u_texel;
|
|
2921
|
-
uniform float u_blur;
|
|
2922
|
-
uniform float u_bloom;
|
|
2923
|
-
uniform float u_bloomThreshold;
|
|
2924
|
-
out vec4 outColor;
|
|
2925
|
-
|
|
2926
|
-
void main() {
|
|
2927
|
-
vec4 c = texture(u_tex, v_uv);
|
|
2928
|
-
if (u_blur < 0.5 && u_bloom < 0.01) {
|
|
2929
|
-
outColor = c;
|
|
2930
|
-
return;
|
|
2931
|
-
}
|
|
2932
|
-
vec4 sum = c;
|
|
2933
|
-
float w = 0.0;
|
|
2934
|
-
if (u_blur >= 0.5) {
|
|
2935
|
-
sum = vec4(0.0);
|
|
2936
|
-
w = 0.0;
|
|
2937
|
-
for (int x = -2; x <= 2; x++) {
|
|
2938
|
-
for (int y = -2; y <= 2; y++) {
|
|
2939
|
-
vec2 off = vec2(float(x), float(y)) * u_texel * u_blur;
|
|
2940
|
-
vec4 s = texture(u_tex, v_uv + off);
|
|
2941
|
-
float weight = 1.0 / (1.0 + float(x*x + y*y));
|
|
2942
|
-
sum += s * weight;
|
|
2943
|
-
w += weight;
|
|
2944
|
-
}
|
|
2945
|
-
}
|
|
2946
|
-
sum /= w;
|
|
2947
|
-
}
|
|
2948
|
-
vec3 bloom = vec3(0.0);
|
|
2949
|
-
if (u_bloom > 0.01) {
|
|
2950
|
-
float lum = dot(sum.rgb, vec3(0.299, 0.587, 0.114));
|
|
2951
|
-
if (lum > u_bloomThreshold) {
|
|
2952
|
-
bloom = sum.rgb * u_bloom * (lum - u_bloomThreshold);
|
|
2953
|
-
}
|
|
2954
|
-
}
|
|
2955
|
-
outColor = vec4(clamp(sum.rgb + bloom, 0.0, 1.0), c.a);
|
|
2956
|
-
}
|
|
2957
|
-
`;
|
|
2958
|
-
var WebGLCompositor = class {
|
|
2959
|
-
gl = null;
|
|
2960
|
-
program = null;
|
|
2961
|
-
vao = null;
|
|
2962
|
-
texture = null;
|
|
2963
|
-
isSupported;
|
|
2964
|
-
constructor() {
|
|
2965
|
-
if (typeof document === "undefined") {
|
|
2966
|
-
this.isSupported = false;
|
|
2967
|
-
return;
|
|
2968
|
-
}
|
|
2969
|
-
const canvas = document.createElement("canvas");
|
|
2970
|
-
canvas.width = 2;
|
|
2971
|
-
canvas.height = 2;
|
|
2972
|
-
const gl = canvas.getContext("webgl2", { premultipliedAlpha: true, alpha: true });
|
|
2973
|
-
if (!gl) {
|
|
2974
|
-
this.isSupported = false;
|
|
2975
|
-
return;
|
|
2976
|
-
}
|
|
2977
|
-
this.gl = gl;
|
|
2978
|
-
this.isSupported = this.initProgram(gl);
|
|
2979
|
-
}
|
|
2980
|
-
initProgram(gl) {
|
|
2981
|
-
const vs = this.compileShader(gl, gl.VERTEX_SHADER, VERTEX_SRC);
|
|
2982
|
-
const fs = this.compileShader(gl, gl.FRAGMENT_SHADER, FRAGMENT_SRC);
|
|
2983
|
-
if (!vs || !fs) return false;
|
|
2984
|
-
const program = gl.createProgram();
|
|
2985
|
-
if (!program) return false;
|
|
2986
|
-
gl.attachShader(program, vs);
|
|
2987
|
-
gl.attachShader(program, fs);
|
|
2988
|
-
gl.linkProgram(program);
|
|
2989
|
-
if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {
|
|
2990
|
-
console.warn("Compositor program link failed", gl.getProgramInfoLog(program));
|
|
2991
|
-
return false;
|
|
2992
|
-
}
|
|
2993
|
-
this.program = program;
|
|
2994
|
-
const positions = new Float32Array([-1, -1, 0, 1, 1, -1, 1, 1, -1, 1, 0, 0, 1, 1, 1, 0]);
|
|
2995
|
-
const vao = gl.createVertexArray();
|
|
2996
|
-
const vbo = gl.createBuffer();
|
|
2997
|
-
gl.bindVertexArray(vao);
|
|
2998
|
-
gl.bindBuffer(gl.ARRAY_BUFFER, vbo);
|
|
2999
|
-
gl.bufferData(gl.ARRAY_BUFFER, positions, gl.STATIC_DRAW);
|
|
3000
|
-
const locPos = gl.getAttribLocation(program, "a_pos");
|
|
3001
|
-
const locUv = gl.getAttribLocation(program, "a_uv");
|
|
3002
|
-
gl.enableVertexAttribArray(locPos);
|
|
3003
|
-
gl.vertexAttribPointer(locPos, 2, gl.FLOAT, false, 16, 0);
|
|
3004
|
-
gl.enableVertexAttribArray(locUv);
|
|
3005
|
-
gl.vertexAttribPointer(locUv, 2, gl.FLOAT, false, 16, 8);
|
|
3006
|
-
gl.bindVertexArray(null);
|
|
3007
|
-
this.vao = vao;
|
|
3008
|
-
this.texture = gl.createTexture();
|
|
3009
|
-
return true;
|
|
3010
|
-
}
|
|
3011
|
-
compileShader(gl, type, source) {
|
|
3012
|
-
const shader = gl.createShader(type);
|
|
3013
|
-
if (!shader) return null;
|
|
3014
|
-
gl.shaderSource(shader, source);
|
|
3015
|
-
gl.compileShader(shader);
|
|
3016
|
-
if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
|
|
3017
|
-
console.warn(gl.getShaderInfoLog(shader));
|
|
3018
|
-
return null;
|
|
3019
|
-
}
|
|
3020
|
-
return shader;
|
|
3021
|
-
}
|
|
3022
|
-
renderToContext(targetCtx, source, settings) {
|
|
3023
|
-
const gl = this.gl;
|
|
3024
|
-
const program = this.program;
|
|
3025
|
-
if (!gl || !program || !this.isSupported) {
|
|
3026
|
-
targetCtx.clearRect(0, 0, source.width, source.height);
|
|
3027
|
-
targetCtx.drawImage(source, 0, 0);
|
|
3028
|
-
return;
|
|
3029
|
-
}
|
|
3030
|
-
const w = source.width;
|
|
3031
|
-
const h = source.height;
|
|
3032
|
-
const canvas = gl.canvas;
|
|
3033
|
-
if (canvas.width !== w || canvas.height !== h) {
|
|
3034
|
-
canvas.width = w;
|
|
3035
|
-
canvas.height = h;
|
|
3036
|
-
}
|
|
3037
|
-
gl.viewport(0, 0, w, h);
|
|
3038
|
-
gl.clearColor(0, 0, 0, 0);
|
|
3039
|
-
gl.clear(gl.COLOR_BUFFER_BIT);
|
|
3040
|
-
gl.useProgram(program);
|
|
3041
|
-
gl.activeTexture(gl.TEXTURE0);
|
|
3042
|
-
gl.bindTexture(gl.TEXTURE_2D, this.texture);
|
|
3043
|
-
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
|
|
3044
|
-
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
|
|
3045
|
-
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
|
|
3046
|
-
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
|
|
3047
|
-
gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, true);
|
|
3048
|
-
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, source);
|
|
3049
|
-
gl.uniform1i(gl.getUniformLocation(program, "u_tex"), 0);
|
|
3050
|
-
gl.uniform2f(gl.getUniformLocation(program, "u_texel"), 1 / w, 1 / h);
|
|
3051
|
-
gl.uniform1f(gl.getUniformLocation(program, "u_blur"), settings.blur ?? 0);
|
|
3052
|
-
gl.uniform1f(gl.getUniformLocation(program, "u_bloom"), settings.bloom ?? 0);
|
|
3053
|
-
gl.uniform1f(gl.getUniformLocation(program, "u_bloomThreshold"), settings.bloomThreshold ?? 0.6);
|
|
3054
|
-
gl.bindVertexArray(this.vao);
|
|
3055
|
-
gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
|
|
3056
|
-
gl.bindVertexArray(null);
|
|
3057
|
-
targetCtx.clearRect(0, 0, w, h);
|
|
3058
|
-
targetCtx.drawImage(canvas, 0, 0);
|
|
3059
|
-
}
|
|
3060
|
-
dispose() {
|
|
3061
|
-
const gl = this.gl;
|
|
3062
|
-
if (!gl) return;
|
|
3063
|
-
if (this.texture) gl.deleteTexture(this.texture);
|
|
3064
|
-
if (this.program) gl.deleteProgram(this.program);
|
|
3065
|
-
if (this.vao) gl.deleteVertexArray(this.vao);
|
|
3066
|
-
this.gl = null;
|
|
3067
|
-
}
|
|
3068
|
-
};
|
|
3069
|
-
|
|
3070
2356
|
// src/engine/mask.ts
|
|
3071
2357
|
function applyMaskReveal(ctx, doc, width, height) {
|
|
3072
2358
|
const maskLayer = doc.effectLayers.find((l) => l.type === "mask" && l.enabled);
|
|
@@ -3094,14 +2380,6 @@ function applyMaskReveal(ctx, doc, width, height) {
|
|
|
3094
2380
|
}
|
|
3095
2381
|
|
|
3096
2382
|
// src/engine/evaluate.ts
|
|
3097
|
-
var sharedCompositor = null;
|
|
3098
|
-
function getCompositor() {
|
|
3099
|
-
if (typeof document === "undefined") return null;
|
|
3100
|
-
if (!sharedCompositor) {
|
|
3101
|
-
sharedCompositor = new WebGLCompositor();
|
|
3102
|
-
}
|
|
3103
|
-
return sharedCompositor;
|
|
3104
|
-
}
|
|
3105
2383
|
function evaluateScene(doc, time, ctx, options = {}) {
|
|
3106
2384
|
const animated = applyTimelineAtTime(doc, time);
|
|
3107
2385
|
const cfg = sceneToConfig(animated);
|
|
@@ -3128,11 +2406,21 @@ function evaluateScene(doc, time, ctx, options = {}) {
|
|
|
3128
2406
|
tctx.clearRect(0, 0, w, h);
|
|
3129
2407
|
renderTextEffectCore(tctx, cfg);
|
|
3130
2408
|
applyMaskReveal(tctx, animated, w, h);
|
|
3131
|
-
|
|
3132
|
-
if (
|
|
3133
|
-
|
|
2409
|
+
ctx.clearRect(0, 0, w, h);
|
|
2410
|
+
if (supportsCtxFilter()) {
|
|
2411
|
+
ctx.save();
|
|
2412
|
+
const blur = Math.max(0, comp.blur);
|
|
2413
|
+
const bloom = Math.max(0, comp.bloom);
|
|
2414
|
+
if (blur > 0) ctx.filter = `blur(${blur}px)`;
|
|
2415
|
+
ctx.drawImage(temp, 0, 0);
|
|
2416
|
+
if (bloom > 0) {
|
|
2417
|
+
ctx.globalCompositeOperation = "screen";
|
|
2418
|
+
ctx.globalAlpha = Math.min(0.8, bloom * 0.25);
|
|
2419
|
+
ctx.filter = `blur(${Math.max(1, bloom * 4)}px)`;
|
|
2420
|
+
ctx.drawImage(temp, 0, 0);
|
|
2421
|
+
}
|
|
2422
|
+
ctx.restore();
|
|
3134
2423
|
} else {
|
|
3135
|
-
ctx.clearRect(0, 0, w, h);
|
|
3136
2424
|
ctx.drawImage(temp, 0, 0);
|
|
3137
2425
|
}
|
|
3138
2426
|
CanvasDevice.release(temp);
|