mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-15 22:28:10 +08:00
* Support Linear line segments, add linear section to interactive docs * Fix regression, customize points in UI examples, add optional subdivisions to length, minor refactors * Refactor ExamplePane, use better example curves * Update consts.rs comments * Code review changes * Address PR comments * Code review Co-authored-by: Keavon Chambers <keavon@keavon.com>
65 lines
1.3 KiB
Vue
65 lines
1.3 KiB
Vue
<template>
|
|
<div>
|
|
<h4 class="example-header">{{ title }}</h4>
|
|
<figure class="example-figure" ref="drawing"></figure>
|
|
</div>
|
|
</template>
|
|
|
|
<script lang="ts">
|
|
import { defineComponent, PropType } from "vue";
|
|
|
|
import BezierDrawing from "@/components/BezierDrawing";
|
|
import { BezierCallback, WasmBezierInstance } from "@/utils/types";
|
|
|
|
export default defineComponent({
|
|
name: "ExampleComponent",
|
|
data() {
|
|
return {
|
|
bezierDrawing: new BezierDrawing(this.bezier, this.callback, this.options, this.createThroughPoints),
|
|
};
|
|
},
|
|
props: {
|
|
title: String,
|
|
bezier: {
|
|
type: Object as PropType<WasmBezierInstance>,
|
|
required: true,
|
|
},
|
|
callback: {
|
|
type: Function as PropType<BezierCallback>,
|
|
required: true,
|
|
},
|
|
options: {
|
|
type: Object as PropType<Record<string, number>>,
|
|
default: () => ({}),
|
|
},
|
|
createThroughPoints: {
|
|
type: Boolean as PropType<boolean>,
|
|
default: false,
|
|
},
|
|
},
|
|
mounted() {
|
|
const drawing = this.$refs.drawing as HTMLElement;
|
|
drawing.appendChild(this.bezierDrawing.getCanvas());
|
|
this.bezierDrawing.updateBezier();
|
|
},
|
|
watch: {
|
|
options: {
|
|
deep: true,
|
|
handler() {
|
|
this.bezierDrawing.updateBezier(undefined, this.options);
|
|
},
|
|
},
|
|
},
|
|
});
|
|
</script>
|
|
|
|
<style scoped>
|
|
.example-header {
|
|
margin-bottom: 0;
|
|
}
|
|
|
|
.example-figure {
|
|
margin-top: 0.5em;
|
|
}
|
|
</style>
|