feat: load background file

This commit is contained in:
2026-06-24 06:48:13 +05:00
parent 680dad30bf
commit 3b49c9f3c2
7 changed files with 242 additions and 3 deletions
+12
View File
@@ -2,6 +2,16 @@ import { computeHomography } from './homography.js';
function $(id) { return document.getElementById(id); }
function applyBgToField(field, state) {
if (state.bgImage) {
field.style.backgroundImage = `url(${state.bgImage})`;
field.style.backgroundSize = state.objectFit === 'fill' ? '100% 100%' : state.objectFit;
} else {
field.style.backgroundImage = 'none';
field.style.backgroundSize = '';
}
}
export function updateLivePreview(state) {
const container = $('fieldContainer');
const cw = container.clientWidth;
@@ -18,6 +28,8 @@ export function updateLivePreview(state) {
field.style.transform = `scale(${scale})`;
container.style.height = (state.fieldH * scale) + 'px';
applyBgToField(field, state);
const widget = $('widget');
widget.style.width = state.widgetW + 'px';
widget.style.height = state.widgetH + 'px';