MCPcopy
hub / github.com/Lightricks/ComfyUI-LTXVideo / loadBgImage

Function loadBgImage

web/js/sparse_track_editor.js:262–282  ·  view source on GitHub ↗
(node, b64)

Source from the content-addressed store, hash-verified

260// ---------------------------------------------------------------------------
261
262function loadBgImage(node, b64) {
263 const ed = node._ed;
264 const img = new window.Image();
265 img.onload = () => {
266 const firstLoad = ed.bgImg === null;
267 ed.bgImg = img;
268 ed.imgW = img.width;
269 ed.imgH = img.height;
270 if (firstLoad && ed.splines.length === 1 && ed.splines[0].length === 2) {
271 ed.splines[0][0] = { x: ed.imgW * 0.3, y: ed.imgH * 0.5 };
272 ed.splines[0][1] = { x: ed.imgW * 0.7, y: ed.imgH * 0.5 };
273 }
274 ed.dirty = true;
275 syncWidgets(node);
276 requestAnimationFrame(() => {
277 node.setSize?.(node.computeSize());
278 app.graph?.setDirtyCanvas(true, true);
279 });
280 };
281 img.src = `data:image/jpeg;base64,${b64}`;
282}
283
284// ---------------------------------------------------------------------------
285// Coordinate transforms (image space <-> canvas pixel space)

Callers 1

beforeRegisterNodeDefFunction · 0.85

Calls 1

syncWidgetsFunction · 0.85

Tested by

no test coverage detected