Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
@daeinc/geom
Advanced tools
A collection of gemetry-related functions. Breaking changes expected in the future.
npm i @daeinc/geom
then,
import { blendPath, ... } from "@daeinc/geom";
import { blendPath, ... } from "https://cdn.jsdelivr.net/npm/@daeinc/geom/dist/geom.esm.js"
type Pt = number[];
type Pts = number[][];
type GenericObject = Record<string, any>;
Three custom types are used.
const blendPath: (
path1: Pts,
path2: Pts,
numBlends: number,
guidePath?: Pts,
) => number[][][];
Interpolates two paths to create in-between paths. numBlends
does not count the two original paths. In other words, the two original paths are not included in the return array. guidePath
parameter is not yet implemented.
const createShapeFunc: (
pts: Pts,
anchor?: Pt,
) => (x: number, y: number, w: number, h: number) => Pts;
const dist: (pt1: Pt, pt2: Pt) => number;
Returns a distance between two points.
const distSq: (pt1: Pt, pt2: Pt) => number;
Returns a squared distance between two points. There's another version in @daeinc/math
that takes number
arguments.
const extrudePath: (
path: Pts,
numPointsToExtrude: number,
offset: Pt,
mode?: "start" | "end" | "both",
shapeFunc?: () => Pts,
) => number[][];
Extrudes a path in 2d space.
const generateSmoothPath: (pts: Pts, smoothFactor: number) => number[][];
Generates extra points for smooth corners of path. Use with drawSmoothPath()
from another package, @daeinc/canvas
const getAngleBetween: (pt1: Pt, pt2: Pt) => number;
Get angle between two points using Math.atan2()
. Return value is between -pi and pi. pt2 - pt1
is the order of subtraction.
const getPathLength: (path: Pts) => number;
Returns the total length of path
const getPositiveAngleBetween: (pt1: Pt, pt2: Pt) => number;
Return value is between 0 and 2pi.
const getSegmentLengths: (pts: Pts) => number[];
Returns an array with each segment length (distance between points).
const interpolateArray: (
arrStart: number[],
arrTarget: number[],
t: number,
) => number[];
const interpolatePath: (
pathStart: Pts,
pathTarget: Pts,
t: number,
) => number[][];
Interpolates between two number arrays. Usually used for path data of [x, y]
.
const interpolateObject: (
objStart: GenericObject,
objTarget: GenericObject,
t: number,
) => GenericObject;
Interpolates between two objects formatted { string: number }
. For example, { x: 10, y: 20 }
.
const interpolate: <T>(
start: T,
target: T,
t: number,
) => number | GenericObject | T;
Interpolates number
, number[]
, number[][]
or generic object.
const projectPointOnLine: (pt: Pt, line: Pts) => Pt;
Projects a point on a line.
const reflectPoint: (pt: Pt, axis: Pt | Pts) => Pt;
Reflects a point on another point or a line.
const reflectPath: (pts: Pts, axis: Pt | Pts) => Pts;
Reflects a path either on a point or a line.
const scalePoint: (pt: Pt, size: Pt) => Pt;
Scales a single point.
const scalePath: (path: Pts, size: Pt) => Pts;
Takes in normalized path data and returns [ x, y ]
that is scaled to size, [ width, height ]
.
Float32Array
(gl-vec2
) and regular arrayMIT
FAQs
Geometry utilities
The npm package @daeinc/geom receives a total of 105 weekly downloads. As such, @daeinc/geom popularity was classified as not popular.
We found that @daeinc/geom demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.