diff --git a/package.json b/package.json index a436456..842c097 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@sciux/monorepo", "type": "module", - "version": "0.0.6", + "version": "0.0.7", "private": true, "packageManager": "pnpm@10.4.0", "scripts": { diff --git a/packages/layout/package.json b/packages/layout/package.json index 6819fe6..495287a 100644 --- a/packages/layout/package.json +++ b/packages/layout/package.json @@ -1,7 +1,7 @@ { "name": "@sciux/layout", "type": "module", - "version": "0.0.6", + "version": "0.0.7", "description": "Layout components for SciuxKit", "author": "BijonAI ", "license": "MIT", diff --git a/packages/math/package.json b/packages/math/package.json index 47339da..4fd84cb 100644 --- a/packages/math/package.json +++ b/packages/math/package.json @@ -1,7 +1,7 @@ { "name": "@sciux/math", "type": "module", - "version": "0.0.6", + "version": "0.0.7", "description": "Layout components for SciuxKit", "author": "BijonAI ", "license": "MIT", diff --git a/packages/math/src/angle/points.ts b/packages/math/src/angle/points.ts index c306304..5de75b9 100644 --- a/packages/math/src/angle/points.ts +++ b/packages/math/src/angle/points.ts @@ -47,7 +47,7 @@ export const angleEndPoint = defineComponent<'end-point', typeof InfoPointType.i ] return { name: 'end-point', - attrs: InfoPointType, + attrs: InfoPointType, globals: (() => { if ('as' in attrs) { return { @@ -91,5 +91,14 @@ export const origin = defineComponent<'origin', typeof InfoPointType.infer, { container.append(texElement) return container }, + defaults: { + value: '', + }, + setup() { + const container = document.createElementNS('http://www.w3.org/2000/svg', 'g') + const texElement = generateTexNode(attrs.value.value) + container.append(texElement) + return container + }, } }) diff --git a/packages/math/src/dot/index.ts b/packages/math/src/dot/index.ts new file mode 100644 index 0000000..4cf82e0 --- /dev/null +++ b/packages/math/src/dot/index.ts @@ -0,0 +1,40 @@ +import { theme } from '@sciux/utils-theme' +import { type } from 'arktype' +import { defineComponent } from 'sciux-laplace' +import { generateTexNode } from '../utils/tex' + +const T = type({ + x: type.number, + y: type.number, + label: 'string | undefined', +}) + +export const dot = defineComponent<'dot', typeof T.infer, { division: number | undefined }>((attrs, context) => { + return { + name: 'dot', + attrs: T, + defaults: { + x: 0, + y: 0, + }, + setup() { + const container = document.createElementNS('http://www.w3.org/2000/svg', 'g') + container.setAttribute('transform', `translate(${attrs.x.value * (context.division ?? 1)}, ${attrs.y.value * (context.division ?? 1)})`) + + const dotSvg = document.createElementNS('http://www.w3.org/2000/svg', 'circle') + dotSvg.id = 'dot-circle' + container.id = 'canvas-dot' + dotSvg.setAttribute('stroke', 'none') + dotSvg.setAttribute('fill', theme.pallete('primary')) + dotSvg.setAttribute('r', '2') + + if (attrs.label.value) { + const label = generateTexNode(attrs.label.value) + container.append(label) + } + + container.appendChild(dotSvg) + return container + }, + } +}) diff --git a/packages/math/src/index.ts b/packages/math/src/index.ts index 09621eb..67d9fe6 100644 --- a/packages/math/src/index.ts +++ b/packages/math/src/index.ts @@ -1,6 +1,7 @@ export * from './angle' export * from './axis' export * from './circle' +export * from './dot' export * from './figure' export * from './function' export * from './line' diff --git a/packages/model/package.json b/packages/model/package.json index 996677b..243cca5 100644 --- a/packages/model/package.json +++ b/packages/model/package.json @@ -1,7 +1,7 @@ { "name": "@sciux/model", "type": "module", - "version": "0.0.6", + "version": "0.0.7", "description": "Model components for SciuxKit", "author": "BijonAI ", "license": "MIT", diff --git a/packages/sciux/package.json b/packages/sciux/package.json index d596438..8f64b7c 100644 --- a/packages/sciux/package.json +++ b/packages/sciux/package.json @@ -1,7 +1,7 @@ { "name": "sciux", "type": "module", - "version": "0.0.6", + "version": "0.0.7", "description": "Sciux library composed package.", "author": "BijonAI ", "license": "MIT", diff --git a/packages/sciux/src/math.ts b/packages/sciux/src/math.ts index 97929f5..7fe108f 100644 --- a/packages/sciux/src/math.ts +++ b/packages/sciux/src/math.ts @@ -1,6 +1,6 @@ import type { Animation, Component } from 'sciux-laplace' import type { RegisterContext } from './types' -import { angle, angleArcCreation, angleCreation, axis, axisCreation, circle, circleCreation, figure, func, funcCreation, line, lineCreation, parametric, parametricCreation, plane, planeCreation, projectionCreation, tools, vector, vectorCreation } from '@sciux/math' +import { angle, angleArcCreation, angleCreation, axis, axisCreation, circle, circleCreation, dot, figure, func, funcCreation, line, lineCreation, parametric, parametricCreation, plane, planeCreation, projectionCreation, tools, vector, vectorCreation } from '@sciux/math' import { withSpace } from 'sciux-laplace' import { canvasSpace } from './widget' @@ -14,6 +14,7 @@ export default function ({ animations, context }: RegisterContext): void { canvasSpace.set('axis', axis) canvasSpace.set('plane', withSpace(plane as Component<'plane', any, any>, canvasSpace)) canvasSpace.set('parametric', parametric) + canvasSpace.set('dot', dot) const creation = []> animations.get('creation') creation.push(angleCreation, angleArcCreation, circleCreation, lineCreation, funcCreation, parametricCreation, axisCreation, planeCreation, projectionCreation, vectorCreation) Object.assign(context, tools) diff --git a/packages/theme-default/package.json b/packages/theme-default/package.json index 6335ced..5b0043b 100644 --- a/packages/theme-default/package.json +++ b/packages/theme-default/package.json @@ -1,7 +1,7 @@ { "name": "@sciux/theme-default", "type": "module", - "version": "0.0.6", + "version": "0.0.7", "description": "Default theme for SciuxKit", "author": "BijonAI ", "license": "MIT", diff --git a/packages/utils-theme/package.json b/packages/utils-theme/package.json index 9c62a66..f11945c 100644 --- a/packages/utils-theme/package.json +++ b/packages/utils-theme/package.json @@ -1,7 +1,7 @@ { "name": "@sciux/utils-theme", "type": "module", - "version": "0.0.6", + "version": "0.0.7", "description": "Theme utilities for SciuxKit", "author": "BijonAI ", "license": "MIT", diff --git a/packages/widget/package.json b/packages/widget/package.json index aef372b..aea7635 100644 --- a/packages/widget/package.json +++ b/packages/widget/package.json @@ -1,7 +1,7 @@ { "name": "@sciux/widget", "type": "module", - "version": "0.0.6", + "version": "0.0.7", "description": "Widgets for SciuxKit", "author": "BijonAI ", "license": "MIT", diff --git a/test/src/examples.ts b/test/src/examples.ts index a5a018f..0986d95 100644 --- a/test/src/examples.ts +++ b/test/src/examples.ts @@ -4,6 +4,7 @@ import ins02 from './template/instance/ins02.sciux?raw' import angle from './template/math/angle.sciux?raw' import axis from './template/math/axis.sciux?raw' import circle from './template/math/circle.sciux?raw' +import dot from './template/math/dot.sciux?raw' import figure from './template/math/figure.sciux?raw' import parametric from './template/math/parametric.sciux?raw' import plane from './template/math/plane.sciux?raw' @@ -22,6 +23,7 @@ export default { plane, parametric, axis, + dot, }, 'INSTANCE': { ins01, diff --git a/test/src/template/instance/ins02.sciux b/test/src/template/instance/ins02.sciux index d6f1838..7972b37 100644 --- a/test/src/template/instance/ins02.sciux +++ b/test/src/template/instance/ins02.sciux @@ -14,6 +14,7 @@ + - - - + + + - - + \ No newline at end of file diff --git a/test/src/template/math/dot.sciux b/test/src/template/math/dot.sciux new file mode 100644 index 0000000..4dcd3eb --- /dev/null +++ b/test/src/template/math/dot.sciux @@ -0,0 +1,5 @@ + + + + +