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

Function initEditor

web/js/sparse_track_editor.js:155–237  ·  view source on GitHub ↗
(node)

Source from the content-addressed store, hash-verified

153// ---------------------------------------------------------------------------
154
155function initEditor(node) {
156 const pointsW = node.widgets.find((w) => w.name === "points_store");
157 const coordsW = node.widgets.find((w) => w.name === "coordinates");
158 hideWidget(pointsW);
159 hideWidget(coordsW);
160
161 const ed = {
162 splines: [],
163 active: 0,
164 imgW: 1024,
165 imgH: 576,
166 bgImg: null,
167 drag: null,
168 hover: null,
169 canvas: null,
170 ctx: null,
171 menu: null,
172 dirty: true,
173 rafId: null,
174 };
175 node._ed = ed;
176
177 // Restore saved state
178 try {
179 const saved = JSON.parse(pointsW.value);
180 if (Array.isArray(saved) && saved.length > 0) {
181 ed.splines = saved;
182 }
183 } catch (_) {
184 /* first run */
185 }
186 if (ed.splines.length === 0) {
187 ed.splines = [
188 [
189 { x: ed.imgW * 0.3, y: ed.imgH * 0.5 },
190 { x: ed.imgW * 0.7, y: ed.imgH * 0.5 },
191 ],
192 ];
193 }
194
195 // DOM
196 const container = document.createElement("div");
197 container.style.position = "relative";
198 container.style.minHeight = `${CANVAS_MIN_HEIGHT}px`;
199
200 const canvas = document.createElement("canvas");
201 canvas.width = 1024;
202 canvas.height = 576;
203 canvas.style.width = "100%";
204 canvas.style.display = "block";
205 canvas.style.background = "#1a1a2e";
206 canvas.style.borderRadius = "4px";
207 canvas.style.cursor = "default";
208 canvas.style.pointerEvents = "auto";
209 canvas.style.touchAction = "none";
210 container.appendChild(canvas);
211 ed.canvas = canvas;
212 ed.ctx = canvas.getContext("2d");

Callers 1

nodeCreatedFunction · 0.85

Calls 5

hideWidgetFunction · 0.85
buildContextMenuFunction · 0.85
setupEventsFunction · 0.85
syncWidgetsFunction · 0.85
startRenderLoopFunction · 0.85

Tested by

no test coverage detected