Bounding box

This commit is contained in:
2024-12-02 17:43:32 +01:00
parent ffc15e4d52
commit fa74e1e15a
2 changed files with 24 additions and 12 deletions

View File

@@ -4,6 +4,7 @@
import Drag from "./Drag.svelte"; import Drag from "./Drag.svelte";
let ws: WebSocket | null = $state(null); let ws: WebSocket | null = $state(null);
let image: HTMLImageElement | null = $state(null);
let parent: HTMLElement | null = $state(null); let parent: HTMLElement | null = $state(null);
@@ -21,8 +22,18 @@
}); });
</script> </script>
<div bind:this={parent} class="relative border border-red-500"> <div class="relative">
<img src="/scene_drawing.png" alt="moradi" class="absolute" /> <img src="/bg.png" alt="" bind:this={image} class="scale-50" />
<div
bind:this={parent}
class="absolute inset-0 border border-red-500"
style={"width: " +
image?.getBoundingClientRect().width +
"px; height: " +
image?.getBoundingClientRect().height +
"px;" +
"transform: translate(50%, 50%);"}
>
{#each trackers as tracker} {#each trackers as tracker}
<Drag <Drag
bind:id={tracker.id} bind:id={tracker.id}
@@ -33,3 +44,4 @@
/> />
{/each} {/each}
</div> </div>
</div>

View File

@@ -68,7 +68,7 @@
onpointerup={onPointerUp} onpointerup={onPointerUp}
onpointermove={onPointerMove} onpointermove={onPointerMove}
style={`transform: translate(${vis_x}px, ${vis_y}px)`} style={`transform: translate(${vis_x}px, ${vis_y}px)`}
class="absolute flex h-40 w-40 touch-none items-center justify-center rounded-full border-red-400 bg-red-400" class="absolute flex h-40 w-40 touch-none select-none items-center justify-center rounded-full border-red-400 bg-red-400"
> >
Tracker {id} Tracker {id}
</div> </div>