This commit is contained in:
Đăng Nguyễn
2025-10-03 11:31:14 +07:00
parent 2853340856
commit c5686e4ecf
9 changed files with 871 additions and 647 deletions

View File

@@ -5,12 +5,23 @@
};
}
window.getElementBoundingRect = (element) => {
const rect = element.getBoundingClientRect();
return {
width: rect.width,
height: rect.height,
x: rect.x,
y: rect.y,
left: rect.left,
top: rect.top
};
}
window.setCanvasSize = (canvas, width, height) => {
canvas.width = width;
canvas.height = height;
}
// Image loading and caching functionality
window.imageCache = new Map();
window.preloadImage = (imagePath) => {
@@ -47,11 +58,6 @@ window.preloadImageFromUrl = (url, cacheKey) => {
img.onerror = (error) => {
reject(new Error(`Failed to load image from URL: ${url}`));
};
// Don't set crossOrigin for same-origin requests
// Only set it if you're loading from a different domain
// img.crossOrigin = 'anonymous';
img.src = url;
});
};