RectText component

This commit is contained in:
Jörn-Michael Miehe 2023-01-24 11:35:45 +00:00
parent 049763a411
commit a55d1a25ba
2 changed files with 43 additions and 4 deletions

View file

@ -14,12 +14,13 @@
:rectangle="rect" :rectangle="rect"
@click.left="choose_rect(index)" @click.left="choose_rect(index)"
/> />
<Rect <template
v-for="(rect, index) in rectangles_chosen" v-for="(rect, index) in rectangles_chosen"
:key="'rect_chosen' + index" :key="'rect_chosen' + index"
:rectangle="rect" >
:focused="true" <Rect :rectangle="rect" :focused="true" />
/> <RectText :rectangle="rect" :text="String(index)" />
</template>
</ThouCanvas> </ThouCanvas>
</figure> </figure>
</section> </section>
@ -31,11 +32,13 @@ import { Rectangle } from "../rects/rectangles";
import ThouCanvas from "../rects/ThouCanvas.vue"; import ThouCanvas from "../rects/ThouCanvas.vue";
import Rect from "../rects/Rect.vue"; import Rect from "../rects/Rect.vue";
import RectText from "../rects/RectText.vue";
@Options({ @Options({
components: { components: {
ThouCanvas, ThouCanvas,
Rect, Rect,
RectText,
}, },
props: { props: {
rectangles: Array, rectangles: Array,

View file

@ -0,0 +1,36 @@
<template>
<text
:x="rectangle.left + 0.5 * rectangle.width"
:y="rectangle.top + 0.5 * rectangle.height"
text-anchor="middle"
dominant-baseline="middle"
>
{{ text }}
</text>
</template>
<script lang="ts">
import { Vue, Options } from "vue-class-component";
import { Rectangle } from "./rectangles";
@Options({
props: {
rectangle: Rectangle,
text: String,
},
})
export default class RectText extends Vue {
private rectangle!: Rectangle;
private text!: string;
}
</script>
<style lang="scss" scoped>
text {
fill: red;
font-weight: bold;
font-size: 40px;
font-stretch: condensed;
}
</style>