(node, b64)
| 260 | // --------------------------------------------------------------------------- |
| 261 | |
| 262 | function 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) |
no test coverage detected