page: 📄 透明度

This commit is contained in:
bunny 2024-07-11 14:18:11 +08:00
parent 7253d71880
commit c104971c0b
1 changed files with 46 additions and 0 deletions

View File

@ -0,0 +1,46 @@
<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 pentagon = new Konva.RegularPolygon({
x: stage.width() / 2,
y: stage.height() / 2,
sides: 5,
radius: 70,
fill: 'red',
stroke: 'black',
strokeWidth: 4,
opacity: 0.2,
});
pentagon.on('mouseover', function () {
this.opacity(1);
});
pentagon.on('mouseout', function () {
this.opacity(0.2);
});
layer.add(pentagon);
stage.add(layer);
};
onMounted(() => {
initial();
});
</script>