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

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

"devDependencies": {
"@leafer/interface": "1.0.0-rc.19"
"@leafer/interface": "1.0.0-rc.20"
}
}

@@ -62,4 +62,4 @@ import { IBounds, IBoundsData, IMatrixData, IPointData, IBoundsDataFn, IObject, IMatrix, IRadiusPointData, IMatrixWithLayoutData, IFourNumber } from '@leafer/interface'

public getFitMatrix(put: IBoundsData): IMatrix {
return B.getFitMatrix(this, put)
public getFitMatrix(put: IBoundsData, baseScale?: number): IMatrix {
return B.getFitMatrix(this, put, baseScale)
}

@@ -124,2 +124,7 @@

public addPoint(point: IPointData): IBounds {
B.addPoint(this, point)
return this
}
public getPoints(): IPointData[] {

@@ -170,2 +175,4 @@ return B.getPoints(this)

}
}
export const tempBounds = new Bounds()

@@ -164,4 +164,4 @@ import { IPointData, IBoundsData, IMatrixData, IFourNumber, IBoundsDataFn, IObject, IMatrix, IOffsetBoundsData, IRadiusPointData, IMatrixWithScaleData } from '@leafer/interface'

getFitMatrix(t: IBoundsData, put: IBoundsData): IMatrix {
const scale = Math.min(1, Math.min(t.width / put.width, t.height / put.height))
getFitMatrix(t: IBoundsData, put: IBoundsData, baseScale = 1): IMatrix {
const scale = Math.min(baseScale, Math.min(t.width / put.width, t.height / put.height))
return new Matrix(scale, 0, 0, scale, -put.x * scale, -put.y * scale)

@@ -207,8 +207,13 @@ },

add(t: IBoundsData, bounds: IBoundsData): void {
add(t: IBoundsData, bounds: IBoundsData, isPoint?: boolean): void {
right = t.x + t.width
bottom = t.y + t.height
boundsRight = bounds.x + bounds.width
boundsBottom = bounds.y + bounds.height
boundsRight = bounds.x
boundsBottom = bounds.y
if (!isPoint) {
boundsRight += bounds.width
boundsBottom += bounds.height
}
right = right > boundsRight ? right : boundsRight

@@ -258,2 +263,6 @@ bottom = bottom > boundsBottom ? bottom : boundsBottom

addPoint(t: IBoundsData, point: IPointData): void {
add(t, point as IBoundsData, true)
},
getPoints(t: IBoundsData): IPointData[] {

@@ -260,0 +269,0 @@ const { x, y, width, height } = t

export { IncrementId } from './IncrementId'
export { Point } from './Point'
export { Bounds } from './Bounds'
export { Point, tempPoint } from './Point'
export { Bounds, tempBounds } from './Bounds'
export { AutoBounds } from './AutoBounds'
export { Matrix } from './Matrix'
export { Matrix, tempMatrix } from './Matrix'

@@ -8,0 +8,0 @@ export { PointHelper } from './PointHelper'

@@ -15,3 +15,3 @@ import { IPointData, IBoundsData, IMatrixData } from '@leafer/interface'

if (value instanceof Array) {
if (isFourNumber) value = MathHelper.fourNumber(value)
if (isFourNumber) value = MathHelper.fourNumber(value, 0)
for (let i = 0; i < value.length; i++) value[i] = -value[i]

@@ -29,3 +29,3 @@ } else {

case 4:
data = num
data = maxValue === undefined ? num : [...num]
break

@@ -32,0 +32,0 @@ case 2:

@@ -14,2 +14,5 @@ import { IMatrix, IMatrixData, IPointData, ILayoutData, IMatrixWithScaleData } from '@leafer/interface'

public scaleX: number
public scaleY: number
constructor(a?: number | IMatrixData, b?: number, c?: number, d?: number, e?: number, f?: number) {

@@ -24,2 +27,9 @@ this.set(a, b, c, d, e, f)

public setWith(dataWithScale: IMatrixWithScaleData): IMatrix {
M.copy(this, dataWithScale)
this.scaleX = dataWithScale.scaleX
this.scaleY = dataWithScale.scaleY
return this
}
public get(): IMatrixData {

@@ -50,2 +60,9 @@ const { a, b, c, d, e, f } = this

public scaleWith(x: number, y?: number): IMatrix {
M.scale(this, x, y)
this.scaleX *= x
this.scaleY *= y || x
return this
}
public scaleOfOuter(origin: IPointData, x: number, y?: number): IMatrix {

@@ -118,3 +135,10 @@ M.scaleOfOuter(this, origin, x, y)

public invertWith(): IMatrix {
M.invert(this)
this.scaleX = 1 / this.scaleX
this.scaleY = 1 / this.scaleY
return this
}
public toOuterPoint(inner: IPointData, to?: IPointData, distance?: boolean): void {

@@ -146,2 +170,4 @@ M.toOuterPoint(this, inner, to, distance)

}
}
export const tempMatrix = new Matrix()

@@ -96,2 +96,4 @@ import { IPoint, IPointData, IMatrixData } from '@leafer/interface'

}
}
export const tempPoint = new Point()

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

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

@@ -35,2 +35,3 @@ declare const IncrementId: {

}
declare const tempPoint: Point;

@@ -55,3 +56,3 @@ declare class Bounds implements IBounds {

toInnerOf(matrix: IMatrixData, to?: IBoundsData): IBounds;
getFitMatrix(put: IBoundsData): IMatrix;
getFitMatrix(put: IBoundsData, baseScale?: number): IMatrix;
spread(fourNumber: IFourNumber, spreadY?: number): IBounds;

@@ -68,2 +69,3 @@ shrink(fourNumber: IFourNumber): IBounds;

setPoints(points: IPointData[]): IBounds;
addPoint(point: IPointData): IBounds;
getPoints(): IPointData[];

@@ -80,2 +82,3 @@ hitPoint(point: IPointData, pointMatrix?: IMatrixData): boolean;

}
declare const tempBounds: Bounds;

@@ -102,4 +105,7 @@ declare class AutoBounds implements IAutoBounds {

f: number;
scaleX: number;
scaleY: number;
constructor(a?: number | IMatrixData, b?: number, c?: number, d?: number, e?: number, f?: number);
set(a?: number | IMatrixData, b?: number, c?: number, d?: number, e?: number, f?: number): IMatrix;
setWith(dataWithScale: IMatrixWithScaleData): IMatrix;
get(): IMatrixData;

@@ -110,2 +116,3 @@ clone(): IMatrix;

scale(x: number, y?: number): IMatrix;
scaleWith(x: number, y?: number): IMatrix;
scaleOfOuter(origin: IPointData, x: number, y?: number): IMatrix;

@@ -124,2 +131,3 @@ scaleOfInner(origin: IPointData, x: number, y?: number): IMatrix;

invert(): IMatrix;
invertWith(): IMatrix;
toOuterPoint(inner: IPointData, to?: IPointData, distance?: boolean): void;

@@ -132,2 +140,3 @@ toInnerPoint(outer: IPointData, to?: IPointData, distance?: boolean): void;

}
declare const tempMatrix: Matrix;

@@ -192,3 +201,3 @@ declare const PointHelper: {

toInnerOf(t: IBoundsData, matrix: IMatrixData, to?: IBoundsData): void;
getFitMatrix(t: IBoundsData, put: IBoundsData): IMatrix;
getFitMatrix(t: IBoundsData, put: IBoundsData, baseScale?: number): IMatrix;
getSpread(t: IBoundsData, spreadX: IFourNumber, spreadY?: number): IBoundsData;

@@ -199,3 +208,3 @@ spread(t: IBoundsData, spreadX: IFourNumber, spreadY?: IFourNumber): void;

float(t: IBoundsData, maxLength?: number): void;
add(t: IBoundsData, bounds: IBoundsData): void;
add(t: IBoundsData, bounds: IBoundsData, isPoint?: boolean): void;
addList(t: IBoundsData, list: IBoundsData[]): void;

@@ -206,2 +215,3 @@ setList(t: IBoundsData, list: IBoundsData[], addMode?: boolean): void;

setPoints(t: IBoundsData, points: IPointData[]): void;
addPoint(t: IBoundsData, point: IPointData): void;
getPoints(t: IBoundsData): IPointData[];

@@ -298,2 +308,2 @@ hitRadiusPoint(t: IBoundsData, point: IRadiusPointData, pointMatrix?: IMatrixWithScaleData): boolean;

export { AroundHelper, AutoBounds, Bounds, BoundsHelper, Direction4, Direction9, IncrementId, MathHelper, Matrix, MatrixHelper, OneRadian, PI2, PI_2, Point, PointHelper, StringNumberMap, TwoPointBoundsHelper, getBoundsData, getMatrixData, getPointData };
export { AroundHelper, AutoBounds, Bounds, BoundsHelper, Direction4, Direction9, IncrementId, MathHelper, Matrix, MatrixHelper, OneRadian, PI2, PI_2, Point, PointHelper, StringNumberMap, TwoPointBoundsHelper, getBoundsData, getMatrixData, getPointData, tempBounds, tempMatrix, tempPoint };