Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
1385e9d
chore: add package `@sciux/math`
sheepbox8646 Jun 12, 2025
c27bac9
chore: change package path name
sheepbox8646 Jun 12, 2025
4665bf1
Merge branch 'main' into feat/math
sheepbox8646 Jun 12, 2025
15c793d
ci: add tsconfig for each package
sheepbox8646 Jun 12, 2025
284afcc
feat: `<angle>`, and it's dependent components
sheepbox8646 Jun 13, 2025
b0653c1
feat: tex, data-point, tex-on-angle-mark
sheepbox8646 Jun 14, 2025
935c176
feat: line
sheepbox8646 Jun 14, 2025
1220767
Merge branch 'main' into feat/math
sheepbox8646 Jun 14, 2025
8273d1e
Merge branch 'main' into feat/math
sheepbox8646 Jun 14, 2025
bff91a3
feat: line and it's dependent comps
sheepbox8646 Jun 17, 2025
ddf3f24
feat: figure
sheepbox8646 Jun 17, 2025
abc5900
feat: circle
sheepbox8646 Jun 17, 2025
6cfbeae
Merge branch 'main' into feat/math
sheepbox8646 Jun 18, 2025
6ad88ab
feat(math): add color pallete support for math comps
sheepbox8646 Jun 18, 2025
8b04be7
feat: `<function>` & `<axis>` & `<plane>`
sheepbox8646 Jun 19, 2025
ecc7049
feat: plane grid
sheepbox8646 Jun 20, 2025
ba39351
Merge branch 'main' into feat/math
sheepbox8646 Jun 21, 2025
90d99e3
feat: function-creation animation
sheepbox8646 Jun 21, 2025
8d41070
ci: update dependencies
sheepbox8646 Jun 24, 2025
297db15
ci: update denpendencies
sheepbox8646 Jun 27, 2025
97f21ec
Merge branch 'main' into feat/math
sheepbox8646 Jul 2, 2025
1d6da08
feat: parametric
sheepbox8646 Jul 2, 2025
57714f6
feat: creation animatiom of line & angle & arc
sheepbox8646 Jul 4, 2025
8864ee1
feat: circle animation
sheepbox8646 Jul 4, 2025
e4a17f3
feat: point mark of angle
sheepbox8646 Jul 4, 2025
0426342
fix: angle src radius calculate
Jul 4, 2025
e73e4df
feat: Use right angle markers when the angle is right angle
Jul 4, 2025
c1edeb3
ci: update dependencies
sheepbox8646 Jul 4, 2025
3e4c0d0
feat: creation animation of axis, plane
sheepbox8646 Jul 5, 2025
9e52dc4
feat: add component `<mermaid>`
Jul 5, 2025
bce6fa8
feat: projection
sheepbox8646 Jul 5, 2025
a10b967
feat: vector
sheepbox8646 Jul 5, 2025
3848406
feat: add tools
sheepbox8646 Jul 5, 2025
765c5e5
feat: support <point> components without an "as" attribute
Jul 9, 2025
7cfc19a
feat: add dot (#12)
onion108 Jul 10, 2025
d8c43de
fix: defaults value
sheepbox8646 Jul 10, 2025
2195b55
feat: add needed default value
sheepbox8646 Jul 10, 2025
07fa9f1
Merge branch 'main' into feat/math
sheepbox8646 Jul 10, 2025
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
2 changes: 2 additions & 0 deletions packages/math/src/angle/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ export const angle = defineComponent<'angle', typeof T.infer>((attrs) => {
endSide: 10,
startSideType: 'solid',
endSideType: 'solid',
x: 0,
y: 0,
},
setup(children) {
const container = document.createElementNS('http://www.w3.org/2000/svg', 'g')
Expand Down
37 changes: 29 additions & 8 deletions packages/math/src/angle/points.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,13 @@
return {
name: 'start-point',
attrs: InfoPointType,
globals: {
[attrs.as.value]: position,
},
globals: (() => {
if ('as' in attrs) {
return {
[attrs.as.value]: position,
}
}
})(),
defaults: {
value: '',
},
Expand All @@ -44,9 +48,13 @@
return {
name: 'end-point',
attrs: InfoPointType,
globals: {
[attrs.as.value]: position,
},
globals: (() => {
if ('as' in attrs) {
return {
[attrs.as.value]: position,
}
}
})(),
defaults: {
value: '',
},
Expand All @@ -67,13 +75,26 @@
return {
name: 'origin',
attrs: InfoPointType,
globals: {
[attrs.as.value]: [context.x, context.y],
globals: (() => {
if ('as' in attrs) {
return {
[attrs.as.value]: [context.x, context.y],
}
}
})(),
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
},
defaults: {

Check failure on line 94 in packages/math/src/angle/points.ts

View workflow job for this annotation

GitHub Actions / lint

An object literal cannot have multiple properties with the same name.
value: '',
},
setup() {

Check failure on line 97 in packages/math/src/angle/points.ts

View workflow job for this annotation

GitHub Actions / lint

Duplicate identifier 'setup'.
const container = document.createElementNS('http://www.w3.org/2000/svg', 'g')
const texElement = generateTexNode(attrs.value.value)
container.append(texElement)
Expand Down
3 changes: 3 additions & 0 deletions packages/math/src/axis/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { type } from 'arktype'
import { defineAnimation, defineComponent } from 'sciux-laplace'

const T = type({

Check warning on line 6 in packages/math/src/axis/index.ts

View workflow job for this annotation

GitHub Actions / lint

'T' is assigned a value but only used as a type. Allowed unused vars must match /^_/u
x: type.number,
y: type.number,
division: type.number,
Expand All @@ -11,7 +11,7 @@
label: type.unknown,
direction: type.enumerated('top', 'bottom', 'left', 'right'),
})
interface withLabelT {

Check warning on line 14 in packages/math/src/axis/index.ts

View workflow job for this annotation

GitHub Actions / lint

'withLabelT' is defined but never used. Allowed unused vars must match /^_/u
label: (count: number) => string
}

Expand All @@ -27,6 +27,9 @@
// division: 20,
label: (count: number) => count.toString(),
direction: 'right',
x: 0,
y: 0,
range: [-5, 5],
},
setup(children) {
const root = document.createElementNS('http://www.w3.org/2000/svg', 'g')
Expand Down
23 changes: 15 additions & 8 deletions packages/math/src/circle/points.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,21 @@ export const edgePoint = defineComponent<
}
>((attrs, context) => {
const { x, y, radius } = context
const { value, as } = attrs
const { value } = attrs
const point = [
x + radius * Math.cos(value.value),
y + radius * Math.sin(value.value),
]
return {
name: 'edge-points',
attrs: EdgePointType,
globals: {
[as.value]: point,
},
globals: (() => {
if ('as' in attrs) {
return {
[attrs.as.value]: point,
}
}
})(),
}
})

Expand All @@ -42,12 +46,15 @@ export const origin = defineComponent<
y: number
}
>((attrs, context) => {
const { as } = attrs
return {
name: 'origin',
attrs: OriginType,
globals: {
[as.value]: [context.x, context.y],
},
globals: (() => {
if ('as' in attrs) {
return {
[attrs.as.value]: [context.x, context.y],
}
}
})(),
}
})
49 changes: 49 additions & 0 deletions packages/math/src/dot/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
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,
value: type.string,
as: type.string,
})

export const dot = defineComponent<'dot', typeof T.infer, { division: number | undefined }>((attrs, context) => {
return {
name: 'dot',
attrs: T,
defaults: {
x: 0,
y: 0,
value: '',
},
provides: (() => {
if ('as' in attrs) {
return {
[attrs.as.value]: [attrs.x.value * (context.division ?? 1), attrs.y.value * (context.division ?? 1)],
}
}
})(),
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.value.value) {
const label = generateTexNode(attrs.value.value)
container.append(label)
}

container.appendChild(dotSvg)
return container
},
}
})
1 change: 1 addition & 0 deletions packages/math/src/index.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
20 changes: 14 additions & 6 deletions packages/math/src/line/points.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,13 @@ export const lineStartPoint = defineComponent<'start-point', typeof InfoPointTyp
container.append(texElement)
return container
},
globals: {
[attrs.as.value]: context.from,
},
globals: (() => {
if ('as' in attrs) {
return {
[attrs.as.value]: context.from,
}
}
})(),
}
})

Expand All @@ -40,8 +44,12 @@ export const lineEndPoint = defineComponent<'end-point', typeof InfoPointType.in
container.append(texElement)
return container
},
globals: {
[attrs.as.value]: context.to,
},
globals: (() => {
if ('as' in attrs) {
return {
[attrs.as.value]: context.to,
}
}
})(),
}
})
4 changes: 4 additions & 0 deletions packages/math/src/plane/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import { axis } from '../axis'
import { projection } from './projection'

const T = type({

Check warning on line 8 in packages/math/src/plane/index.ts

View workflow job for this annotation

GitHub Actions / lint

'T' is assigned a value but only used as a type. Allowed unused vars must match /^_/u
x: type.number,
y: type.number,
division: type.number,
Expand All @@ -16,7 +16,7 @@
xDirection: type.enumerated('left', 'right'),
yDirection: type.enumerated('top', 'bottom'),
})
interface withLabelT {

Check warning on line 19 in packages/math/src/plane/index.ts

View workflow job for this annotation

GitHub Actions / lint

'withLabelT' is defined but never used. Allowed unused vars must match /^_/u
xLabel: (count: number) => string
yLabel: (count: number) => string
}
Expand All @@ -36,6 +36,10 @@
yLabel: (count: number) => count.toString(),
xDirection: 'right',
yDirection: 'top',
x: 0,
y: 0,
domain: [-5, 5],
range: [-5, 5],
},
setup(children) {
const root = document.createElementNS('http://www.w3.org/2000/svg', 'g')
Expand Down
2 changes: 2 additions & 0 deletions packages/math/src/plane/projection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ export const projection = defineComponent<'projection', typeof T.infer, {
defaults: {
type: 'both',
value: '',
x: 0,
y: 0,
},
setup() {
const container = document.createElementNS('http://www.w3.org/2000/svg', 'g')
Expand Down
3 changes: 3 additions & 0 deletions packages/model/src/checkbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ export default defineComponent<'checkbox', typeof T.infer, Context>((attrs, cont
return {
name: 'checkbox',
attrs: T,
defaults: {
disabled: false,
},
setup: () => {
const input = document.createElement('input')
input.type = 'checkbox'
Expand Down
6 changes: 6 additions & 0 deletions packages/model/src/radio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,18 @@ const T = type({
model: 'string',
group: 'string',
value: 'string',
disabled: 'boolean',
})

export default defineComponent<'radio', typeof T.infer, Context>((attrs, context) => {
return {
name: 'radio',
attrs: T,
defaults: {
value: '',
group: '__default_radio_group',
disabled: false,
},
setup: () => {
const input = document.createElement('input')
input.type = 'radio'
Expand Down
7 changes: 7 additions & 0 deletions packages/model/src/select.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ export const select = defineComponent<'select', typeof SelectType.infer, Context
return {
name: 'select',
attrs: SelectType,
defaults: {
disabled: false,
},
setup: (children) => {
const select = document.createElement('select')
if (attrs.model) {
Expand All @@ -40,6 +43,10 @@ export const selectOption = defineComponent<'option', typeof SelectOptionType.in
return {
name: 'option',
attrs: SelectOptionType,
defaults: {
disabled: false,
value: '__efault_select_option_value',
},
setup: (children) => {
option.value = toValue(attrs.value)
option.selected = toValue(attrs.selected)
Expand Down
4 changes: 4 additions & 0 deletions packages/model/src/slider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ export default defineComponent<'slider', typeof T.infer, Context>((attrs, contex
return {
name: 'slider',
attrs: T,
defaults: {
value: 0,
disabled: false,
},
setup: () => {
const input = document.createElement('input')
input.type = 'range'
Expand Down
3 changes: 2 additions & 1 deletion packages/sciux/src/math.ts
Original file line number Diff line number Diff line change
@@ -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'

Expand All @@ -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 = <Animation<[], any, any>[]> animations.get('creation')
creation.push(angleCreation, angleArcCreation, circleCreation, lineCreation, funcCreation, parametricCreation, axisCreation, planeCreation, projectionCreation, vectorCreation)
Object.assign(context, tools)
Expand Down
Loading
Loading