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-rc.17
to
1.0.0-rc.18
+2
-2
package.json
{
"name": "@leafer/math",
"version": "1.0.0-rc.17",
"version": "1.0.0-rc.18",
"description": "@leafer/math",

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

"devDependencies": {
"@leafer/interface": "1.0.0-rc.17"
"@leafer/interface": "1.0.0-rc.18"
}
}

@@ -1,3 +0,4 @@

import { IBounds, IBoundsData, IMatrixData, IPointData, IBoundsDataFn, IObject, IMatrix, IRadiusPointData, IMatrixWithLayoutData } from '@leafer/interface'
import { IBounds, IBoundsData, IMatrixData, IPointData, IBoundsDataFn, IObject, IMatrix, IRadiusPointData, IMatrixWithLayoutData, IFourNumber } from '@leafer/interface'
import { BoundsHelper as B } from './BoundsHelper'
import { MathHelper } from './MathHelper'

@@ -65,7 +66,12 @@

public spread(spreadX: number, spreadY?: number): IBounds {
B.spread(this, spreadX, spreadY)
public spread(fourNumber: IFourNumber, spreadY?: number): IBounds {
B.spread(this, fourNumber, spreadY)
return this
}
public shrink(fourNumber: IFourNumber): IBounds {
B.spread(this, MathHelper.minus(fourNumber, true))
return this
}
public ceil(): IBounds {

@@ -72,0 +78,0 @@ B.ceil(this)

@@ -1,2 +0,2 @@

import { IPointData, IBoundsData, IMatrixData, IBoundsDataFn, IObject, IMatrix, IOffsetBoundsData, IRadiusPointData, IMatrixWithScaleData } from '@leafer/interface'
import { IPointData, IBoundsData, IMatrixData, IFourNumber, IBoundsDataFn, IObject, IMatrix, IOffsetBoundsData, IRadiusPointData, IMatrixWithScaleData } from '@leafer/interface'
import { Matrix } from './Matrix'

@@ -11,3 +11,3 @@ import { MatrixHelper as M } from './MatrixHelper'

const { toOuterPoint } = M
const { float } = MathHelper
const { float, fourNumber } = MathHelper
const { floor, ceil } = Math

@@ -37,5 +37,10 @@

copyAndSpread(t: IBoundsData, bounds: IBoundsData, spreadX: number, spreadY?: number): void {
if (!spreadY) spreadY = spreadX
B.set(t, bounds.x - spreadX, bounds.y - spreadY, bounds.width + spreadX * 2, bounds.height + spreadY * 2)
copyAndSpread(t: IBoundsData, bounds: IBoundsData, spreadX: IFourNumber, spreadY?: number): void {
if (spreadX instanceof Array) {
const four = fourNumber(spreadX)
B.set(t, bounds.x - four[3], bounds.y - four[0], bounds.width + four[1] + four[3], bounds.height + four[2] + four[0])
} else {
if (!spreadY) spreadY = spreadX
B.set(t, bounds.x - spreadX, bounds.y - spreadY, bounds.width + spreadX * 2, bounds.height + spreadY * 2)
}
},

@@ -167,3 +172,3 @@

getSpread(t: IBoundsData, spreadX: number, spreadY?: number): IBoundsData {
getSpread(t: IBoundsData, spreadX: IFourNumber, spreadY?: number): IBoundsData {
const n = {} as IBoundsData

@@ -174,4 +179,4 @@ B.copyAndSpread(n, t, spreadX, spreadY)

spread(t: IBoundsData, spreadX: number, spreadY = spreadX): void {
B.copyAndSpread(t, t, spreadX, spreadY)
spread(t: IBoundsData, spreadX: IFourNumber, spreadY = spreadX): void {
B.copyAndSpread(t, t, spreadX, spreadY as number)
},

@@ -178,0 +183,0 @@

@@ -13,2 +13,12 @@ import { IPointData, IBoundsData, IMatrixData } from '@leafer/interface'

minus(value: number | number[], isFourNumber: boolean): number | number[] {
if (value instanceof Array) {
if (isFourNumber) value = MathHelper.fourNumber(value)
for (let i = 0; i < value.length; i++) value[i] = -value[i]
} else {
value = -value
}
return value
},
fourNumber(num: number | number[], maxValue?: number): number[] { // top right bottom left || topLeft, topRight, bottomRight, bottomLeft

@@ -15,0 +25,0 @@ let data: number[]

@@ -1,2 +0,2 @@

import { INumberMap, IPoint, IPointData, IMatrixData, IBounds, IBoundsData, IMatrix, IObject, IBoundsDataFn, IRadiusPointData, IMatrixWithLayoutData, IAutoBounds, IAutoBoundsData, ISizeData, ILayoutData, IMatrixWithScaleData, IAround, IOffsetBoundsData, ITwoPointBoundsData, IMatrixWithOptionScaleData, IScaleData } from '@leafer/interface';
import { INumberMap, IPoint, IPointData, IMatrixData, IBounds, IBoundsData, IMatrix, IFourNumber, IObject, IBoundsDataFn, IRadiusPointData, IMatrixWithLayoutData, IAutoBounds, IAutoBoundsData, ISizeData, ILayoutData, IMatrixWithScaleData, IAround, IOffsetBoundsData, ITwoPointBoundsData, IMatrixWithOptionScaleData, IScaleData } from '@leafer/interface';

@@ -55,3 +55,4 @@ declare const IncrementId: {

getFitMatrix(put: IBoundsData): IMatrix;
spread(spreadX: number, spreadY?: number): IBounds;
spread(fourNumber: IFourNumber, spreadY?: number): IBounds;
shrink(fourNumber: IFourNumber): IBounds;
ceil(): IBounds;

@@ -170,3 +171,3 @@ unsign(): IBounds;

copy(t: IBoundsData, bounds: IBoundsData): void;
copyAndSpread(t: IBoundsData, bounds: IBoundsData, spreadX: number, spreadY?: number): void;
copyAndSpread(t: IBoundsData, bounds: IBoundsData, spreadX: IFourNumber, spreadY?: number): void;
minX(t: IBoundsData): number;

@@ -186,4 +187,4 @@ minY(t: IBoundsData): number;

getFitMatrix(t: IBoundsData, put: IBoundsData): IMatrix;
getSpread(t: IBoundsData, spreadX: number, spreadY?: number): IBoundsData;
spread(t: IBoundsData, spreadX: number, spreadY?: number): void;
getSpread(t: IBoundsData, spreadX: IFourNumber, spreadY?: number): IBoundsData;
spread(t: IBoundsData, spreadX: IFourNumber, spreadY?: IFourNumber): void;
ceil(t: IBoundsData): void;

@@ -222,2 +223,3 @@ unsign(t: IBoundsData): void;

within(value: number, min: number, max: number): number;
minus(value: number | number[], isFourNumber: boolean): number | number[];
fourNumber(num: number | number[], maxValue?: number): number[];

@@ -224,0 +226,0 @@ formatRotation(rotation: number, unsign?: boolean): number;