<script setup lang="ts">
import { useWindowSize } from '@vueuse/core';
import { onMounted } from 'vue';
import Konva from 'konva/lib';

const { width, height } = useWindowSize();

const initial = () => {
	const stage = new Konva.Stage({ container: 'container', width: width.value, height: height.value });
	const layer = new Konva.Layer();
	stage.add(layer);

	const circle = new Konva.Circle({
		x: 150,
		y: 150,
		radius: 70,
		fill: 'red',
		draggable: true,
	});
	layer.add(circle);

	const tr = new Konva.Transformer({
		anchorStroke: 'black',
		anchorStrokeWidth: 10,
		anchorFill: 'blue',
		anchorSize: 40,
		borderDash: [6, 6],
		borderStroke: 'green',
		nodes: [circle],
	});
	layer.add(tr);
};

onMounted(() => {
	initial();
});
</script>

<template>
	<div id="container"></div>
</template>

<style scoped lang="scss"></style>
