pixi-effects 0.36.0 → 0.37.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/CHANGELOG.md +17 -0
- package/README.md +5 -5
- package/ai/chat-template.html +3 -3
- package/ai/tools/check.mjs +12 -2
- package/ai/tools/lookup.mjs +2 -1
- package/dist/{Base-CmiFiwQM.d.cts → Base-BlA6SeqJ.d.cts} +1 -1
- package/dist/{Base-CdF7AJop.d.ts → Base-YqM0Ljvp.d.ts} +1 -1
- package/dist/Composition-5KZETM4J.js +7 -0
- package/dist/{Composition-BMRCE5FH.js.map → Composition-5KZETM4J.js.map} +1 -1
- package/dist/Composition-MHDI7UNZ.cjs +16 -0
- package/dist/{Composition-XRLYR6GL.cjs.map → Composition-MHDI7UNZ.cjs.map} +1 -1
- package/dist/Controller.d.cts +2 -2
- package/dist/Controller.d.ts +2 -2
- package/dist/{Movie-D5WFfZdZ.d.ts → Movie-CJN_gvLB.d.cts} +21 -2
- package/dist/{Movie-Bh1HPdKw.d.cts → Movie-CfHaGmUP.d.ts} +21 -2
- package/dist/{Spans-MWP2FX3T.js → Spans-FSSO2HGX.js} +6 -6
- package/dist/{Spans-MWP2FX3T.js.map → Spans-FSSO2HGX.js.map} +1 -1
- package/dist/{Spans-4IRBSOLI.cjs → Spans-WVJH77BW.cjs} +11 -11
- package/dist/{Spans-4IRBSOLI.cjs.map → Spans-WVJH77BW.cjs.map} +1 -1
- package/dist/{blendModes-KU7XLV7U.cjs → blendModes-FD3THLNC.cjs} +5 -5
- package/dist/{blendModes-KU7XLV7U.cjs.map → blendModes-FD3THLNC.cjs.map} +1 -1
- package/dist/{blendModes-OOI3T6BE.js → blendModes-FMYO6SQN.js} +4 -4
- package/dist/{blendModes-OOI3T6BE.js.map → blendModes-FMYO6SQN.js.map} +1 -1
- package/dist/{chunk-2JFFKHXO.js → chunk-32MMNDDN.js} +4 -3
- package/dist/chunk-32MMNDDN.js.map +1 -0
- package/dist/{chunk-42ML5AKN.cjs → chunk-3SAS3ZE5.cjs} +4 -3
- package/dist/chunk-3SAS3ZE5.cjs.map +1 -0
- package/dist/{chunk-CC7SUR7Q.cjs → chunk-E26M4NTL.cjs} +122 -41
- package/dist/chunk-E26M4NTL.cjs.map +1 -0
- package/dist/{chunk-AZ6AINSW.js → chunk-IPQNT65V.js} +6 -6
- package/dist/chunk-IPQNT65V.js.map +1 -0
- package/dist/{chunk-NEUPEENI.cjs → chunk-JN7JHNZR.cjs} +5 -5
- package/dist/{chunk-NEUPEENI.cjs.map → chunk-JN7JHNZR.cjs.map} +1 -1
- package/dist/{chunk-VF56PRAA.js → chunk-KNDEKWQO.js} +89 -9
- package/dist/chunk-KNDEKWQO.js.map +1 -0
- package/dist/{chunk-Y5UWFH6Y.cjs → chunk-MJMOPWMK.cjs} +92 -92
- package/dist/chunk-MJMOPWMK.cjs.map +1 -0
- package/dist/{chunk-KJSEQVBV.cjs → chunk-QHIOOK5S.cjs} +333 -26
- package/dist/chunk-QHIOOK5S.cjs.map +1 -0
- package/dist/{chunk-G3DX65HO.js → chunk-SBR75G73.js} +311 -6
- package/dist/chunk-SBR75G73.js.map +1 -0
- package/dist/{chunk-WIIU42FH.js → chunk-VNP7QCJE.js} +4 -4
- package/dist/{chunk-WIIU42FH.js.map → chunk-VNP7QCJE.js.map} +1 -1
- package/dist/index.cjs +41 -33
- package/dist/index.d.cts +32 -6
- package/dist/index.d.ts +32 -6
- package/dist/index.js +5 -5
- package/dist/loader.css +1 -1
- package/dist/present.cjs +5 -5
- package/dist/present.d.cts +2 -2
- package/dist/present.d.ts +2 -2
- package/dist/present.js +5 -5
- package/dist/three.cjs +6 -6
- package/dist/three.d.cts +2 -2
- package/dist/three.d.ts +2 -2
- package/dist/three.js +2 -2
- package/dist/{types-B6zDTU2V.d.ts → types-DvnXXm33.d.cts} +53 -2
- package/dist/{types-B6zDTU2V.d.cts → types-DvnXXm33.d.ts} +53 -2
- package/docs/dsl.md +35 -0
- package/llms-full.txt +221 -5
- package/package.json +1 -1
- package/skills/pixi-effects/SKILL.md +3 -2
- package/skills/pixi-effects/reference/cheatsheet.md +2 -0
- package/skills/pixi-effects/reference/pitfalls.md +4 -0
- package/skills/pixi-effects/reference/recipes.md +177 -3
- package/skills/pixi-effects/template.html +6 -6
- package/dist/Composition-BMRCE5FH.js +0 -7
- package/dist/Composition-XRLYR6GL.cjs +0 -16
- package/dist/chunk-2JFFKHXO.js.map +0 -1
- package/dist/chunk-42ML5AKN.cjs.map +0 -1
- package/dist/chunk-AZ6AINSW.js.map +0 -1
- package/dist/chunk-CC7SUR7Q.cjs.map +0 -1
- package/dist/chunk-G3DX65HO.js.map +0 -1
- package/dist/chunk-KJSEQVBV.cjs.map +0 -1
- package/dist/chunk-VF56PRAA.js.map +0 -1
- package/dist/chunk-Y5UWFH6Y.cjs.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { describeLayer, collectPropKeys } from './chunk-
|
|
1
|
+
import { describeLayer, collectPropKeys } from './chunk-32MMNDDN.js';
|
|
2
2
|
import { suggestName, warnUnknownOptions } from './chunk-BXOCEZ4U.js';
|
|
3
3
|
import * as PIXI from 'pixi.js';
|
|
4
4
|
import { Rectangle, Container, FillGradient, Text, Color, GraphicsPath, Sprite, Texture, Graphics, Assets, Filter, GlProgram, defaultFilterVert, GpuProgram, UniformGroup, TextStyle, CanvasTextMetrics } from 'pixi.js';
|
|
@@ -971,6 +971,17 @@ function noise(x, seed = 0) {
|
|
|
971
971
|
const u = f * f * f * (f * (f * 6 - 15) + 10);
|
|
972
972
|
return a + (b - a) * u;
|
|
973
973
|
}
|
|
974
|
+
function noise2(x, y, seed = 0) {
|
|
975
|
+
if (!Number.isFinite(x) || !Number.isFinite(y)) return 0;
|
|
976
|
+
const i = Math.floor(x), j = Math.floor(y);
|
|
977
|
+
const fx = x - i, fy = y - j;
|
|
978
|
+
const s = fold(seed) * 668265261;
|
|
979
|
+
const corner = (a, b) => mix2(Math.imul((a | 0) + s, 2654435761) ^ Math.imul((b | 0) + 2135587861, 2246822507)) / 2147483648 - 1;
|
|
980
|
+
const ux = fx * fx * fx * (fx * (fx * 6 - 15) + 10), uy = fy * fy * fy * (fy * (fy * 6 - 15) + 10);
|
|
981
|
+
const top = corner(i, j) + (corner(i + 1, j) - corner(i, j)) * ux;
|
|
982
|
+
const bottom = corner(i, j + 1) + (corner(i + 1, j + 1) - corner(i, j + 1)) * ux;
|
|
983
|
+
return top + (bottom - top) * uy;
|
|
984
|
+
}
|
|
974
985
|
|
|
975
986
|
// src/expr/Parser.ts
|
|
976
987
|
var FUNCS = {
|
|
@@ -5718,18 +5729,311 @@ function resolveDim(v, scope) {
|
|
|
5718
5729
|
if (typeof v === "number") return v;
|
|
5719
5730
|
return evaluateExpr(v, scope);
|
|
5720
5731
|
}
|
|
5732
|
+
var MAX_SIZE = 8192;
|
|
5733
|
+
var MIN_RESOLUTION = 0.25;
|
|
5734
|
+
var MAX_RESOLUTION = 4;
|
|
5735
|
+
var NOT_PURE = /\bMath\s*\.\s*random\s*\(|\bDate\s*\.\s*now\s*\(|\bperformance\s*\.\s*now\s*\(|\bnew\s+Date\s*\(/;
|
|
5736
|
+
function seeded(seed) {
|
|
5737
|
+
let a = seed >>> 0;
|
|
5738
|
+
return () => {
|
|
5739
|
+
a = a + 1831565813 >>> 0;
|
|
5740
|
+
let t = a;
|
|
5741
|
+
t = Math.imul(t ^ t >>> 15, t | 1);
|
|
5742
|
+
t ^= t + Math.imul(t ^ t >>> 7, t | 61);
|
|
5743
|
+
return ((t ^ t >>> 14) >>> 0) / 4294967296;
|
|
5744
|
+
};
|
|
5745
|
+
}
|
|
5746
|
+
function offscreen(width, height) {
|
|
5747
|
+
const c = document.createElement("canvas");
|
|
5748
|
+
c.width = Math.max(1, Math.round(width));
|
|
5749
|
+
c.height = Math.max(1, Math.round(height));
|
|
5750
|
+
c.getContext("2d", { willReadFrequently: true });
|
|
5751
|
+
return c;
|
|
5752
|
+
}
|
|
5753
|
+
var CanvasSequence = class extends Sequence {
|
|
5754
|
+
canvas = null;
|
|
5755
|
+
w = 1;
|
|
5756
|
+
h = 1;
|
|
5757
|
+
res = 1;
|
|
5758
|
+
fps = 30;
|
|
5759
|
+
layerW = 1;
|
|
5760
|
+
layerH = 1;
|
|
5761
|
+
seed = 0;
|
|
5762
|
+
smoothing = true;
|
|
5763
|
+
drawFn = null;
|
|
5764
|
+
state;
|
|
5765
|
+
/** The current value of every param: what keyframes move (`params.amount`). */
|
|
5766
|
+
carrier = {};
|
|
5767
|
+
failed = false;
|
|
5768
|
+
warnedDraw = false;
|
|
5769
|
+
warnedPaths = /* @__PURE__ */ new Set();
|
|
5770
|
+
lastKey = "";
|
|
5771
|
+
lastLocal = 0;
|
|
5772
|
+
get canvasSpec() {
|
|
5773
|
+
return this.spec;
|
|
5774
|
+
}
|
|
5775
|
+
pathRouters() {
|
|
5776
|
+
return { params: (path) => this.resolveParam(path) };
|
|
5777
|
+
}
|
|
5778
|
+
async build() {
|
|
5779
|
+
const spec = this.canvasSpec;
|
|
5780
|
+
const who = describeLayer(spec);
|
|
5781
|
+
if (this.duration === void 0) this.duration = this.parent?.duration ?? this.root.duration;
|
|
5782
|
+
const scope = buildScope(this, this.parent, this.root);
|
|
5783
|
+
this.layerW = this.size("width", spec.width, scope, this.parent?.width ?? this.root.width, who);
|
|
5784
|
+
this.layerH = this.size("height", spec.height, scope, this.parent?.height ?? this.root.height, who);
|
|
5785
|
+
const r = spec.resolution;
|
|
5786
|
+
if (r === void 0) this.res = 1;
|
|
5787
|
+
else if (typeof r === "number" && Number.isFinite(r) && r >= MIN_RESOLUTION && r <= MAX_RESOLUTION) this.res = r;
|
|
5788
|
+
else {
|
|
5789
|
+
this.res = typeof r === "number" && Number.isFinite(r) ? Math.min(MAX_RESOLUTION, Math.max(MIN_RESOLUTION, r)) : 1;
|
|
5790
|
+
console.warn(`pixi-effects: ${who}: resolution must be a number from ${MIN_RESOLUTION} to ${MAX_RESOLUTION} (canvas pixels per layer pixel), got ${JSON.stringify(r)}: ${this.res} is used`);
|
|
5791
|
+
}
|
|
5792
|
+
const longest = Math.max(this.layerW, this.layerH);
|
|
5793
|
+
if (longest * this.res > MAX_SIZE) {
|
|
5794
|
+
const fitted = MAX_SIZE / longest;
|
|
5795
|
+
console.warn(`pixi-effects: ${who}: ${this.layerW}\xD7${this.layerH} at resolution ${this.res} would be a canvas of ${Math.round(longest * this.res)} pixels, more than ${MAX_SIZE}: resolution ${Math.round(fitted * 1e3) / 1e3} is used (lower the size or the resolution)`);
|
|
5796
|
+
this.res = fitted;
|
|
5797
|
+
}
|
|
5798
|
+
this.w = Math.max(1, Math.round(this.layerW * this.res));
|
|
5799
|
+
this.h = Math.max(1, Math.round(this.layerH * this.res));
|
|
5800
|
+
this.fps = this.root.frameRate ?? 30;
|
|
5801
|
+
this.seed = typeof spec.seed === "number" && Number.isFinite(spec.seed) ? Math.floor(spec.seed) : 0;
|
|
5802
|
+
this.smoothing = spec.smoothing !== false;
|
|
5803
|
+
const params = spec.params;
|
|
5804
|
+
if (params !== void 0) {
|
|
5805
|
+
if (params === null || typeof params !== "object" || Array.isArray(params)) {
|
|
5806
|
+
console.warn(`pixi-effects: ${who}: params must be an object of numbers, got ${JSON.stringify(params)}: ignored`);
|
|
5807
|
+
} else {
|
|
5808
|
+
const bad = [];
|
|
5809
|
+
for (const [k, v] of Object.entries(params)) {
|
|
5810
|
+
if (typeof v === "number" && Number.isFinite(v)) this.carrier[k] = v;
|
|
5811
|
+
else bad.push(`"${k}"`);
|
|
5812
|
+
}
|
|
5813
|
+
if (bad.length) console.warn(`pixi-effects: ${who}: params ${bad.join(", ")} ${bad.length > 1 ? "are" : "is"} not a number, so ${bad.length > 1 ? "they are" : "it is"} ignored (params holds numbers that keyframes can animate as 'params.<name>')`);
|
|
5814
|
+
}
|
|
5815
|
+
}
|
|
5816
|
+
if (typeof spec.draw === "function") {
|
|
5817
|
+
this.drawFn = spec.draw;
|
|
5818
|
+
if (NOT_PURE.test(spec.draw.toString())) {
|
|
5819
|
+
console.warn(`pixi-effects: ${who}: draw calls Math.random, Date.now, performance.now or new Date, so it is not deterministic: the same frame would draw differently in playback, in a seek and in an export. Use info.random() (seeded), or derive the value from t`);
|
|
5820
|
+
}
|
|
5821
|
+
} else {
|
|
5822
|
+
this.failed = true;
|
|
5823
|
+
console.warn(`pixi-effects: ${who}: a canvas layer needs draw: (ctx, t, info) => { \u2026 } (a function that draws the picture at time t); the layer is drawn as a checkerboard`);
|
|
5824
|
+
}
|
|
5825
|
+
this.canvas = document.createElement("canvas");
|
|
5826
|
+
this.canvas.width = this.w;
|
|
5827
|
+
this.canvas.height = this.h;
|
|
5828
|
+
const sprite = new Sprite({ texture: Texture.from(this.canvas), label: spec.name });
|
|
5829
|
+
if (!this.smoothing) sprite.texture.source.scaleMode = "nearest";
|
|
5830
|
+
sprite.width = this.layerW;
|
|
5831
|
+
sprite.height = this.layerH;
|
|
5832
|
+
this.target = sprite;
|
|
5833
|
+
this.intrinsicWidth = this.layerW;
|
|
5834
|
+
this.intrinsicHeight = this.layerH;
|
|
5835
|
+
this.buildFilters();
|
|
5836
|
+
if (typeof spec.setup === "function" && !this.failed) {
|
|
5837
|
+
try {
|
|
5838
|
+
this.state = await spec.setup(this.info(0));
|
|
5839
|
+
} catch (e) {
|
|
5840
|
+
this.failed = true;
|
|
5841
|
+
this.say(`setup failed: ${e instanceof Error ? e.message : String(e)}; the layer is drawn as a checkerboard`);
|
|
5842
|
+
}
|
|
5843
|
+
}
|
|
5844
|
+
this.drawAt(0);
|
|
5845
|
+
}
|
|
5846
|
+
async awaitFrameAt(local) {
|
|
5847
|
+
this.drawAt(Math.max(0, Math.min(local, this.duration ?? local)));
|
|
5848
|
+
}
|
|
5849
|
+
size(name, v, scope, fallback, who) {
|
|
5850
|
+
if (v === void 0) return fallback;
|
|
5851
|
+
const n = typeof v === "number" ? v : evaluateExpr(v, scope);
|
|
5852
|
+
if (!Number.isFinite(n) || n < 1) {
|
|
5853
|
+
console.warn(`pixi-effects: ${who}: ${name} must be a number of pixels of at least 1 (or an expression), got ${JSON.stringify(v)}: ${fallback} is used`);
|
|
5854
|
+
return fallback;
|
|
5855
|
+
}
|
|
5856
|
+
if (n > MAX_SIZE) {
|
|
5857
|
+
console.warn(`pixi-effects: ${who}: ${name} ${n} is more than ${MAX_SIZE}: ${MAX_SIZE} is used`);
|
|
5858
|
+
return MAX_SIZE;
|
|
5859
|
+
}
|
|
5860
|
+
return n;
|
|
5861
|
+
}
|
|
5862
|
+
say(why) {
|
|
5863
|
+
if (this.warnedDraw) return;
|
|
5864
|
+
this.warnedDraw = true;
|
|
5865
|
+
console.warn(`pixi-effects: ${describeLayer(this.spec)}: ${why}`);
|
|
5866
|
+
}
|
|
5867
|
+
info(local) {
|
|
5868
|
+
const duration = this.duration ?? 0;
|
|
5869
|
+
const start = this.absoluteStart ?? this.at;
|
|
5870
|
+
return {
|
|
5871
|
+
frame: Math.round(local * this.fps),
|
|
5872
|
+
duration,
|
|
5873
|
+
progress: duration > 0 ? local / duration : 0,
|
|
5874
|
+
width: this.layerW,
|
|
5875
|
+
height: this.layerH,
|
|
5876
|
+
resolution: this.res,
|
|
5877
|
+
frameRate: this.fps,
|
|
5878
|
+
params: { ...this.carrier },
|
|
5879
|
+
state: this.state,
|
|
5880
|
+
random: seeded(this.seed),
|
|
5881
|
+
start,
|
|
5882
|
+
time: start + local,
|
|
5883
|
+
canvas: offscreen
|
|
5884
|
+
};
|
|
5885
|
+
}
|
|
5886
|
+
/** Resolve `params.amount` for the keyframe pipeline; a name nobody declared is said once and dropped. */
|
|
5887
|
+
resolveParam(path) {
|
|
5888
|
+
if (path in this.carrier && !path.includes(".")) return { target: this.carrier, prop: path };
|
|
5889
|
+
if (!this.warnedPaths.has(path)) {
|
|
5890
|
+
this.warnedPaths.add(path);
|
|
5891
|
+
const guess = suggestName(path.split(".")[0], Object.keys(this.carrier));
|
|
5892
|
+
console.warn(`pixi-effects: ${describeLayer(this.spec)}: keyframe path params.${path} names no param "${path}"${guess ? `; did you mean "${guess}"?` : ""} (declare it in params with a starting value); skipped`);
|
|
5893
|
+
}
|
|
5894
|
+
return null;
|
|
5895
|
+
}
|
|
5896
|
+
drawAt(local) {
|
|
5897
|
+
const c = this.canvas;
|
|
5898
|
+
if (!c) return;
|
|
5899
|
+
const ctx = c.getContext("2d");
|
|
5900
|
+
if (!ctx) {
|
|
5901
|
+
this.say("this browser gave no 2D context for the layer's canvas, so nothing can be drawn");
|
|
5902
|
+
return;
|
|
5903
|
+
}
|
|
5904
|
+
const key = `${local}|${this.absoluteStart ?? this.at}|${JSON.stringify(this.carrier)}`;
|
|
5905
|
+
if (key === this.lastKey) return;
|
|
5906
|
+
this.lastKey = key;
|
|
5907
|
+
this.lastLocal = local;
|
|
5908
|
+
if (!this.paint(ctx, c, local)) this.lastKey = "";
|
|
5909
|
+
this.target?.texture.source.update();
|
|
5910
|
+
}
|
|
5911
|
+
/** Draws one frame of the layer into `ctx` (the layer's own canvas, or the scratch one of the determinism check). false: `draw` threw. */
|
|
5912
|
+
paint(ctx, c, local) {
|
|
5913
|
+
const hasReset = "reset" in ctx && typeof ctx.reset === "function";
|
|
5914
|
+
const fresh = () => {
|
|
5915
|
+
if (hasReset) ctx.reset();
|
|
5916
|
+
else {
|
|
5917
|
+
ctx.setTransform(1, 0, 0, 1, 0, 0);
|
|
5918
|
+
ctx.clearRect(0, 0, c.width, c.height);
|
|
5919
|
+
}
|
|
5920
|
+
};
|
|
5921
|
+
fresh();
|
|
5922
|
+
if (this.failed || !this.drawFn) {
|
|
5923
|
+
this.checkerboard(ctx, c);
|
|
5924
|
+
return true;
|
|
5925
|
+
}
|
|
5926
|
+
if (!hasReset) ctx.save();
|
|
5927
|
+
let ok = true;
|
|
5928
|
+
try {
|
|
5929
|
+
ctx.scale(this.res, this.res);
|
|
5930
|
+
ctx.imageSmoothingEnabled = this.smoothing;
|
|
5931
|
+
this.drawFn(ctx, local, this.info(local));
|
|
5932
|
+
} catch (e) {
|
|
5933
|
+
if (!hasReset) {
|
|
5934
|
+
ctx.restore();
|
|
5935
|
+
ctx.save();
|
|
5936
|
+
}
|
|
5937
|
+
fresh();
|
|
5938
|
+
this.say(`draw threw at ${local.toFixed(2)} s: ${e instanceof Error ? e.message : String(e)}; that frame is drawn as a checkerboard (the other frames are tried again)`);
|
|
5939
|
+
this.checkerboard(ctx, c);
|
|
5940
|
+
ok = false;
|
|
5941
|
+
}
|
|
5942
|
+
if (!hasReset) ctx.restore();
|
|
5943
|
+
return ok;
|
|
5944
|
+
}
|
|
5945
|
+
/**
|
|
5946
|
+
* Draws each of `times` in two orders and returns the moments where the pictures differ (a draw that uses Math.random, the clock or state that outlives the call), with how much
|
|
5947
|
+
* (channel values that differ, the largest difference out of 255), and how long a draw took. One draw of every moment comes first and is thrown away: a browser can draw a canvas
|
|
5948
|
+
* made in `setup` differently the first time it is used as a source, and a cache a draw fills on its first call is fine. The layer's own canvas is not touched (everything is drawn in a scratch canvas).
|
|
5949
|
+
* A layer that failed, or a draw that throws, is reported in `threw`.
|
|
5950
|
+
*/
|
|
5951
|
+
checkDeterminism(times) {
|
|
5952
|
+
const none = { differs: [], drawMs: 0, threw: [] };
|
|
5953
|
+
if (!this.canvas) return none;
|
|
5954
|
+
if (this.failed || !this.drawFn) return { ...none, threw: [...times] };
|
|
5955
|
+
const scratch = document.createElement("canvas");
|
|
5956
|
+
scratch.width = this.w;
|
|
5957
|
+
scratch.height = this.h;
|
|
5958
|
+
const ctx = scratch.getContext("2d", { willReadFrequently: true });
|
|
5959
|
+
if (!ctx) return none;
|
|
5960
|
+
const keep = this.w * this.h * 4 * times.length <= 96e6;
|
|
5961
|
+
const read2 = () => ctx.getImageData(0, 0, scratch.width, scratch.height).data;
|
|
5962
|
+
const hash = (d) => {
|
|
5963
|
+
let h = 2166136261;
|
|
5964
|
+
for (let i = 0; i < d.length; i++) {
|
|
5965
|
+
h ^= d[i];
|
|
5966
|
+
h = Math.imul(h, 16777619);
|
|
5967
|
+
}
|
|
5968
|
+
return h >>> 0;
|
|
5969
|
+
};
|
|
5970
|
+
const ms = [];
|
|
5971
|
+
const threw = /* @__PURE__ */ new Set();
|
|
5972
|
+
const once = (t, timed) => {
|
|
5973
|
+
const from = performance.now();
|
|
5974
|
+
if (!this.paint(ctx, scratch, t)) threw.add(t);
|
|
5975
|
+
if (timed) {
|
|
5976
|
+
ctx.getImageData(0, 0, 1, 1);
|
|
5977
|
+
ms.push(performance.now() - from);
|
|
5978
|
+
}
|
|
5979
|
+
return read2();
|
|
5980
|
+
};
|
|
5981
|
+
for (const t of times) once(t, false);
|
|
5982
|
+
const first = times.map((t) => {
|
|
5983
|
+
const d = once(t, true);
|
|
5984
|
+
return keep ? d.slice() : hash(d);
|
|
5985
|
+
});
|
|
5986
|
+
const second = [...times].reverse().map((t) => once(t, false)).reverse();
|
|
5987
|
+
scratch.width = scratch.height = 1;
|
|
5988
|
+
const differs = [];
|
|
5989
|
+
times.forEach((t, i) => {
|
|
5990
|
+
const a = first[i], b = second[i];
|
|
5991
|
+
if (typeof a === "number") {
|
|
5992
|
+
if (a !== hash(b)) differs.push({ t, pixels: -1, maxDiff: -1 });
|
|
5993
|
+
return;
|
|
5994
|
+
}
|
|
5995
|
+
let pixels = 0, maxDiff = 0;
|
|
5996
|
+
for (let k = 0; k < a.length; k++) {
|
|
5997
|
+
const d = Math.abs(a[k] - b[k]);
|
|
5998
|
+
if (d) {
|
|
5999
|
+
pixels++;
|
|
6000
|
+
if (d > maxDiff) maxDiff = d;
|
|
6001
|
+
}
|
|
6002
|
+
}
|
|
6003
|
+
if (pixels) differs.push({ t, pixels, maxDiff });
|
|
6004
|
+
});
|
|
6005
|
+
ms.sort((x, y) => x - y);
|
|
6006
|
+
return { differs: differs.filter((d) => !threw.has(d.t)), drawMs: ms.length ? ms[Math.floor(ms.length / 2)] : 0, threw: times.filter((t) => threw.has(t)) };
|
|
6007
|
+
}
|
|
6008
|
+
checkerboard(ctx, c) {
|
|
6009
|
+
const s = 32;
|
|
6010
|
+
for (let y = 0; y < c.height; y += s) for (let x = 0; x < c.width; x += s) {
|
|
6011
|
+
ctx.fillStyle = x / s + y / s & 1 ? "#ff00ff" : "#220022";
|
|
6012
|
+
ctx.fillRect(x, y, s, s);
|
|
6013
|
+
}
|
|
6014
|
+
}
|
|
6015
|
+
destroy() {
|
|
6016
|
+
const texture = this.target?.texture;
|
|
6017
|
+
if (this.canvas) {
|
|
6018
|
+
this.canvas.width = this.canvas.height = 1;
|
|
6019
|
+
this.canvas = null;
|
|
6020
|
+
}
|
|
6021
|
+
super.destroy();
|
|
6022
|
+
texture?.destroy(true);
|
|
6023
|
+
}
|
|
6024
|
+
};
|
|
5721
6025
|
|
|
5722
6026
|
// src/core/Composition.ts
|
|
5723
6027
|
var _CompositionSequence = null;
|
|
5724
6028
|
async function getCompositionSequence() {
|
|
5725
6029
|
if (!_CompositionSequence) {
|
|
5726
|
-
_CompositionSequence = (await import('./Composition-
|
|
6030
|
+
_CompositionSequence = (await import('./Composition-5KZETM4J.js')).CompositionSequence;
|
|
5727
6031
|
}
|
|
5728
6032
|
return _CompositionSequence;
|
|
5729
6033
|
}
|
|
5730
6034
|
var _SpansSequence = null;
|
|
5731
6035
|
async function getSpansSequence() {
|
|
5732
|
-
if (!_SpansSequence) _SpansSequence = (await import('./Spans-
|
|
6036
|
+
if (!_SpansSequence) _SpansSequence = (await import('./Spans-FSSO2HGX.js')).SpansSequence;
|
|
5733
6037
|
return _SpansSequence;
|
|
5734
6038
|
}
|
|
5735
6039
|
var staticTypes = {
|
|
@@ -5741,6 +6045,7 @@ var staticTypes = {
|
|
|
5741
6045
|
camera: CameraSequence,
|
|
5742
6046
|
light: LightSequence,
|
|
5743
6047
|
shader: ShaderSequence,
|
|
6048
|
+
canvas: CanvasSequence,
|
|
5744
6049
|
null: NullSequence
|
|
5745
6050
|
};
|
|
5746
6051
|
var registry2 = {};
|
|
@@ -5774,6 +6079,6 @@ async function buildSequenceTree(specs, parent, root) {
|
|
|
5774
6079
|
return out;
|
|
5775
6080
|
}
|
|
5776
6081
|
|
|
5777
|
-
export { CameraSequence, DEFAULT_FOV, DEG3 as DEG, EXPRESSION_NAMES, FALLOFFS, LIGHT_KINDS, LIGHT_PROPS, LightSequence, MANY_BLURRED, MAX_BLUR, MAX_CASTERS, MAX_LIGHTS, MIN_BLUR, NEAR, NullSequence, SHADOW_TAPS, Sequence, TextSequence, bindClock, bindCounterKeyframes, blurRadius, buildScope, buildSequenceTree, cameraBasis, checkEase, clockTable, contentLength, createTimeline, ensureFilterLibrary, evaluateExpr, flattenSvgPath, focusProblems, homeCamera, homeDistance, layerInitialZ, layerToWorld, lengthen, lightLevel, noise, packLights, parseEase, parseSpring, projectLayer, projectPoint, rand, random, registerSequenceType, remapOf, resolveAt, resolveNumber, spansMeta, springDuration, timeRemapOf };
|
|
5778
|
-
//# sourceMappingURL=chunk-
|
|
5779
|
-
//# sourceMappingURL=chunk-
|
|
6082
|
+
export { CameraSequence, DEFAULT_FOV, DEG3 as DEG, EXPRESSION_NAMES, FALLOFFS, LIGHT_KINDS, LIGHT_PROPS, LightSequence, MANY_BLURRED, MAX_BLUR, MAX_CASTERS, MAX_LIGHTS, MIN_BLUR, NEAR, NullSequence, SHADOW_TAPS, Sequence, TextSequence, bindClock, bindCounterKeyframes, blurRadius, buildScope, buildSequenceTree, cameraBasis, checkEase, clockTable, contentLength, createTimeline, ensureFilterLibrary, evaluateExpr, flattenSvgPath, focusProblems, homeCamera, homeDistance, layerInitialZ, layerToWorld, lengthen, lightLevel, noise, noise2, packLights, parseEase, parseSpring, projectLayer, projectPoint, rand, random, registerSequenceType, remapOf, resolveAt, resolveNumber, spansMeta, springDuration, timeRemapOf, trimPolylines };
|
|
6083
|
+
//# sourceMappingURL=chunk-SBR75G73.js.map
|
|
6084
|
+
//# sourceMappingURL=chunk-SBR75G73.js.map
|