Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] feat(math): Add Ellipse Component #42

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions extensions/math/src/conic_section/ellipse.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<script setup lang="ts">
import {Growable, WidgetOptions} from "@vue-motion/lib";
import { widget } from "@vue-motion/lib";

import { defineWidget } from "@vue-motion/core";
// import { computed } from "vue";

export interface EllipseOptions extends WidgetOptions, Growable {
center: [number, number];
a: number,
b: number,
wid: string,
fillColor?: string
}

// const standardEquation = computed(() => {})
const props = defineProps<EllipseOptions>();
const options = defineWidget<EllipseOptions>(props);
</script>

<template>
<g v-bind="widget(options)">
<circle :id="options.wid" :cx="options.center[0]*100" :cy="options.center[1]*100" r="100" :fill="props.fillColor" stroke="none" :style="{ transform: `matrix(${options.a}, 0, 0, ${options.b}, 0, 0)` }" />
</g>
</template>
1 change: 1 addition & 0 deletions extensions/math/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ export { default as Tex } from './tex.vue'
export { default as PolarPlane } from './polar-plane.vue'
export type { PolarPlaneOptions } from './polar-plane.vue'
export type { TexOptions } from './tex.vue'
export { default as Ellipse} from './conic_section/ellipse.vue'
2 changes: 1 addition & 1 deletion extensions/math/src/math-function.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function generateSvgPath(mathFunc: (x: number) => number, domain: {
for (let x = xMin; x <= xMax; x += step) {
const y = mathFunc(x)

// Convert the values ​​of a mathematical function to SVG coordinates
// Convert the values of a mathematical function to SVG coordinates
const svgX = (x - xMin) * scaleX
const svgY = (yMax - y) * scaleY // Invert the y-axis to conform to the SVG coordinate system

Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/widget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export function defineWidget<T extends Widget>(props: Reactive<T>, methods?: Rec
}
})

return widget
return reactive(widget)
}

export function useWidget<T extends Widget>(wid: string) {
Expand Down
Loading