page: 📄 旋转指定角度

This commit is contained in:
bunny 2024-07-16 10:26:04 +08:00
parent 10ed9a8701
commit d7c704d507
4 changed files with 35 additions and 4 deletions

View File

@ -1,6 +1,4 @@
```sh
rotation snaps
resize snaps
stop transform
force update
text resizing

View File

@ -1 +1 @@
{"version":1721033068639}
{"version":1721089915004}

View File

@ -32,9 +32,9 @@ const initial = () => {
return newBoundBox;
},
nodes: [rect],
});
layer.add(tr);
tr.nodes([rect]);
};
onMounted(() => {

View File

@ -0,0 +1,33 @@
<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 text = new Konva.Text({ x: 50, y: 70, fontSize: 30, text: '旋转', draggable: true });
layer.add(text);
const tr = new Konva.Transformer({
nodes: [text],
centeredScaling: true,
//
rotationSnaps: [0, 90, 180, 270],
resizeEnabled: false,
});
layer.add(tr);
};
onMounted(() => {
initial();
});
</script>
<template>
<div id="container"></div>
</template>