I already managed to do it, it is by taking the size of the layer with Parallax s 100%
/ === 2. GET INSTANCES (Estilo Imagen) ===
const layoutActual = runtime.layout;
const capaHUD = layoutActual.getLayer(nombreCapaHUD);
const lienzo = runtime.objects[nombreTipoCanvas]?.getFirstInstance(); // Usa el nombre correcto
const gv = runtime.globalVars; // Acceso a globales, usado en la parte de dibujo
// === 3. CALCULATE HUD/CANVAS TARGET GEOMETRY (Estilo Imagen) ===
// (Calcula hudVisibleWidth, hudVisibleHeight, hudTopLeftX, hudTopLeftY usando cssPxToLayer)
let hudVisibleWidth = 0, hudVisibleHeight = 0, hudTopLeftX = 0, hudTopLeftY = 0;
let hudIsValid = false;
if (capaHUD && capaHUD.parallaxX === 1 && capaHUD.parallaxY === 1) {
const anchoInternoVentana = window.innerWidth; const altoInternoVentana = window.innerHeight;
if (anchoInternoVentana > 0 && altoInternoVentana > 0) {
try {
[hudTopLeftX, hudTopLeftY] = capaHUD.cssPxToLayer(0, 0);
const [hudBottomRightX, hudBottomRightY] = capaHUD.cssPxToLayer(anchoInternoVentana, altoInternoVentana);
hudVisibleWidth = hudBottomRightX - hudTopLeftX;
hudVisibleHeight = hudBottomRightY - hudTopLeftY;
if (hudVisibleWidth > 0 && hudVisibleHeight > 0) { hudIsValid = true; }
} catch (e) { console.error("[SETUP] Error coord conversion:", e); hudIsValid = false; }
}
}
// === 4. POSITION AND RESIZE CANVAS (Estilo Imagen) ===
// (Ajusta lienzo.x, lienzo.y, lienzo.width, lienzo.height basado en los cálculos anteriores)
let canvasReadyForDrawing = false;
if (hudIsValid && lienzo && lienzo.layer === capaHUD) {
const targetX = hudTopLeftX + margenX; const targetY = hudTopLeftY + margenY;
const targetWidth = hudVisibleWidth; const targetHeight = hudVisibleHeight;
if (lienzo.x !== targetX || lienzo.y !== targetY) { lienzo.x = targetX; lienzo.y = targetY; lienzo.positionChanged = true; }
if (lienzo.width !== targetWidth || lienzo.height !== targetHeight) { lienzo.width = targetWidth; lienzo.height = targetHeight; lienzo.sizeChanged = true; }
if (lienzo.width > 0 && lienzo.height > 0) { canvasReadyForDrawing = true; }
}