You're Invited:Meet the Socket Team at RSAC and BSidesSF 2026, March 23–26.RSVP
Socket
Book a DemoSign in
Socket

@leafer/math

Package Overview
Dependencies
Maintainers
1
Versions
117
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@leafer/math - npm Package Compare versions

Comparing version
1.0.0-alpha.23
to
1.0.0-alpha.30
+2
-2
package.json
{
"name": "@leafer/math",
"version": "1.0.0-alpha.23",
"version": "1.0.0-alpha.30",
"description": "@leafer/math",

@@ -22,4 +22,4 @@ "author": "Chao (Leafer) Wan",

"devDependencies": {
"@leafer/interface": "1.0.0-alpha.23"
"@leafer/interface": "1.0.0-alpha.30"
}
}

@@ -171,11 +171,6 @@ import { IPointData, IBoundsData, IMatrixData, IBoundsDataHandle, IObject, IMatrix, IOffsetBoundsData, IRadiusPointData } from '@leafer/interface'

setByListWithHandle(t: IBoundsData, list: IObject[], boundsDataHandle: IBoundsDataHandle, addMode = false): void {
if (!list.length) {
B.reset(t)
return
}
let bounds: IBoundsData, first = true
for (let i = 0, len = list.length; i < len; i++) {
bounds = boundsDataHandle ? boundsDataHandle(list[i]) : list[i] as IBoundsData
if (bounds && (bounds.width || bounds.height)) { // 必须有效的bounds
if (bounds && (bounds.width || bounds.height)) {
if (first) {

@@ -189,2 +184,4 @@ first = false

}
if (first) B.reset(t)
},

@@ -191,0 +188,0 @@

@@ -13,4 +13,4 @@ export { IncrementId } from './IncrementId'

export { MatrixHelper } from './MatrixHelper'
export { MathHelper, OneRadian } from './MathHelper'
export { MathHelper, OneRadian, PI2, PI_2 } from './MathHelper'
export { StringNumberMap } from './StringNumber'

@@ -7,2 +7,27 @@ export const MathHelper = {

return value
},
fourNumber(num: number | number[]): number[] {
let one: number, two: number, three: number, four: number // = top right bottom left || topLeft, topRight, bottomRight, bottomLeft
if (num instanceof Array) {
switch (num.length) {
case 4:
return num
case 2:
one = three = num[0]
two = four = num[1]
break
case 3:
one = num[0]
two = four = num[1]
three = num[2]
break
case 1:
num = num[0]
break
default:
num = 0
}
}
return one === undefined ? [num as number, num as number, num as number, num as number] : [one, two, three, four]
}

@@ -12,2 +37,4 @@

export const OneRadian = Math.PI / 180
export const OneRadian = Math.PI / 180
export const PI2 = Math.PI * 2
export const PI_2 = Math.PI / 2

@@ -93,2 +93,7 @@ import { IMatrix, IMatrixData, IPointData, IMatrixDecompositionData } from '@leafer/interface'

public preMultiply(matrix: IMatrixData): IMatrix {
M.preMultiply(this, matrix)
return this
}
public divide(matrix: IMatrixData): IMatrix {

@@ -95,0 +100,0 @@ M.divide(this, matrix)

@@ -130,2 +130,16 @@ import { IMatrix, IMatrixData, IPointData, IMatrixDecompositionData } from '@leafer/interface'

preMultiply(t: IMatrixData, matrix: IMatrixData): void {
const { a, b, c, d, e, f } = t
if (matrix.a !== 1 || matrix.b !== 0 || matrix.c !== 0 || matrix.d !== 1) {
t.a = (a * matrix.a) + (b * matrix.c)
t.b = (a * matrix.b) + (b * matrix.d)
t.c = (c * matrix.a) + (d * matrix.c)
t.d = (c * matrix.b) + (d * matrix.d)
}
t.e = (e * matrix.a) + (f * matrix.c) + matrix.e
t.f = (e * matrix.b) + (f * matrix.d) + matrix.f
},
divide(t: IMatrixData, matrix: IMatrixData): void {

@@ -132,0 +146,0 @@ M.multiply(t, M.tempInvert(matrix))

@@ -19,2 +19,6 @@ import { ITwoPointBounds, ITwoPointBoundsData } from '@leafer/interface'

addBounds(x: number, y: number, width: number, height: number): void {
P.addBounds(this, x, y, width, height)
}
add(pb: ITwoPointBoundsData): void {

@@ -21,0 +25,0 @@ P.add(this, pb)

@@ -19,2 +19,14 @@ import { ITwoPointBoundsData, IBoundsData } from '@leafer/interface'

addBounds(t: ITwoPointBoundsData, x: number, y: number, width: number, height: number): void {
addPoint(t, x, y)
addPoint(t, x + width, y + height)
},
copy(t: ITwoPointBoundsData, pb: ITwoPointBoundsData): void {
t.minX = pb.minX
t.minY = pb.minY
t.maxX = pb.maxX
t.maxY = pb.maxY
},
add(t: ITwoPointBoundsData, pb: ITwoPointBoundsData): void {

@@ -34,2 +46,4 @@ t.minX = pb.minX < t.minX ? pb.minX : t.minX

}
}
const { addPoint } = TwoPointBoundsHelper