We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
export function setupCanvas(graph, backgroundImageUrl) { const canvas = new LGraphCanvas("#graph-canvas", graph);
// Load background image if provided if (backgroundImageUrl) { const img = new Image(); img.src = backgroundImageUrl; console.log("Loading image from:", img.src);
img.onload = () => { console.log("Image loaded successfully:", img.src); // Manually draw the background image const ctx = canvas.canvas.getContext("2d"); ctx.drawImage(img, 0, 0, canvas.canvas.width, canvas.canvas.height); console.log("Background image drawn manually"); }; img.onerror = () => { console.error("Failed to load background image:", img.src); };
}
// Zoom Controls document.getElementById("zoom-in").onclick = () => { if (canvas.ds.scale < 2) { // Limit max zoom canvas.ds.scale *= 1.2; canvas.setDirty(true, true); } };
document.getElementById("zoom-out").onclick = () => { if (canvas.ds.scale > 0.2) { // Limit min zoom canvas.ds.scale *= 0.8; canvas.setDirty(true, true); } };
/**
// Handle window resizing window.addEventListener("resize", resizeCanvas); resizeCanvas();
return canvas; }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
export function setupCanvas(graph, backgroundImageUrl) {
const canvas = new LGraphCanvas("#graph-canvas", graph);
// Load background image if provided
if (backgroundImageUrl) {
const img = new Image();
img.src = backgroundImageUrl;
console.log("Loading image from:", img.src);
}
// Zoom Controls
document.getElementById("zoom-in").onclick = () => {
if (canvas.ds.scale < 2) {
// Limit max zoom
canvas.ds.scale *= 1.2;
canvas.setDirty(true, true);
}
};
document.getElementById("zoom-out").onclick = () => {
if (canvas.ds.scale > 0.2) {
// Limit min zoom
canvas.ds.scale *= 0.8;
canvas.setDirty(true, true);
}
};
/**
*/
function resizeCanvas() {
const canvasElement = document.getElementById("graph-canvas");
const container = document.getElementById("graph-container");
canvasElement.width = container.offsetWidth;
canvasElement.height = container.offsetHeight;
canvas.setDirty(true, true);
}
// Handle window resizing
window.addEventListener("resize", resizeCanvas);
resizeCanvas();
return canvas;
}
The text was updated successfully, but these errors were encountered: