From e04757278d5bbd4058b6d3b958307ee893699d93 Mon Sep 17 00:00:00 2001 From: Kai Sassnowski Date: Thu, 22 Aug 2024 11:53:32 +0200 Subject: [PATCH] feat: make components nestable --- src/components/Angle.vue | 6 +++- src/components/Arc.vue | 4 ++- src/components/Circle.vue | 26 ++++++++------ src/components/Ellipse.vue | 30 ++++++++++------- src/components/FunctionPlot.vue | 15 +++++---- src/components/Graph.vue | 10 +++--- src/components/Label.vue | 6 +++- src/components/Line.vue | 6 +++- src/components/Point.vue | 8 +++-- src/components/PolyLine.vue | 4 ++- src/components/Polygon.vue | 8 +++-- src/components/Sector.vue | 24 +++++++------ src/components/Vector.vue | 4 ++- src/composables/useLocalToWorld.ts | 30 ++++++++++------- src/utils/Matrix2D.ts | 54 ++++++++++++++++++------------ tests/math/Matrix2D.test.ts | 13 +++---- 16 files changed, 149 insertions(+), 99 deletions(-) diff --git a/src/components/Angle.vue b/src/components/Angle.vue index d5f5921..ded9518 100644 --- a/src/components/Angle.vue +++ b/src/components/Angle.vue @@ -22,6 +22,8 @@ :color="color" :size="labelSize" /> + + @@ -33,6 +35,7 @@ import { useGraphContext } from "../composables/useGraphContext.ts"; import { Color } from "../types.ts"; import { useColors } from "../composables/useColors.ts"; import { usePointerIntersection } from "../composables/usePointerIntersection.ts"; +import { useLocalToWorld } from "../composables/useLocalToWorld.ts"; import { pointInsideSector } from "../utils/geometry.ts"; import Label from "./Label.vue"; @@ -58,7 +61,8 @@ const props = withDefaults( }, ); -const { matrix, invScale } = useGraphContext(); +const { invScale } = useGraphContext(); +const matrix = useLocalToWorld(toRef(props, "position")); const { parseColor } = useColors(); const stroke = parseColor(toRef(props, "color"), "stroke"); diff --git a/src/components/Arc.vue b/src/components/Arc.vue index 887f0bb..06669bc 100644 --- a/src/components/Arc.vue +++ b/src/components/Arc.vue @@ -10,7 +10,9 @@ :color="color" :label="label" :label-size="labelSize" - /> + > + +