page: 📄 lineJoin 显示
This commit is contained in:
parent
9f1c53b7ef
commit
8c9163bc0c
|
@ -0,0 +1,47 @@
|
||||||
|
<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 triangle = new Konva.RegularPolygon({
|
||||||
|
x: stage.width() / 2,
|
||||||
|
y: stage.height() / 2,
|
||||||
|
sides: 3,
|
||||||
|
radius: 70,
|
||||||
|
fill: 'red',
|
||||||
|
stroke: 'black',
|
||||||
|
strokeWidth: 20,
|
||||||
|
lineJoin: 'bevel',
|
||||||
|
});
|
||||||
|
|
||||||
|
triangle.on('mouseover', function () {
|
||||||
|
this.lineJoin('round');
|
||||||
|
});
|
||||||
|
|
||||||
|
triangle.on('mouseout', function () {
|
||||||
|
this.lineJoin('bevel');
|
||||||
|
});
|
||||||
|
|
||||||
|
layer.add(triangle);
|
||||||
|
stage.add(layer);
|
||||||
|
};
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
initial();
|
||||||
|
});
|
||||||
|
</script>
|
Loading…
Reference in New Issue