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

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

const { width, height } = useWindowSize();

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

	const layer = new Konva.Layer({ draggable: true });

	const cuttomShape = new Konva.Shape({
		x: 16,
		y: 30,
		width: width.value/2,
		height: height.value/2,
		sceneFunc(context, shape) {
			context.beginPath();

			context.rect(0, 0, shape.getAttr('width'), shape.getAttr('height'));
			context.fillStrokeShape(shape);
		},
		fill: '#00D2FF',
		stroke: 'black',
		strokeWidth: 4,
	});

	layer.add(cuttomShape);
	stage.add(layer);
};

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