page: 📄 旋转指定角度
This commit is contained in:
parent
10ed9a8701
commit
d7c704d507
|
@ -1,6 +1,4 @@
|
|||
```sh
|
||||
rotation snaps
|
||||
resize snaps
|
||||
stop transform
|
||||
force update
|
||||
text resizing
|
||||
|
|
|
@ -1 +1 @@
|
|||
{"version":1721033068639}
|
||||
{"version":1721089915004}
|
|
@ -32,9 +32,9 @@ const initial = () => {
|
|||
|
||||
return newBoundBox;
|
||||
},
|
||||
nodes: [rect],
|
||||
});
|
||||
layer.add(tr);
|
||||
tr.nodes([rect]);
|
||||
};
|
||||
|
||||
onMounted(() => {
|
|
@ -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>
|
Loading…
Reference in New Issue