New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@tldraw/primitives

Package Overview
Dependencies
Maintainers
4
Versions
461
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tldraw/primitives - npm Package Compare versions

Comparing version 2.0.0-canary.f687c9f64 to 2.0.0-canary.f745781056d5

dist-cjs/lib/BaseSegment2d.js

88

CHANGELOG.md

@@ -0,1 +1,89 @@

# v2.0.0-alpha.13 (Wed Jun 28 2023)
### Release Notes
#### [refactor] snapping ([#1589](https://github.com/tldraw/tldraw/pull/1589))
- [editor] fix bug in snapping
#### Fix arrows with weird bends crashing ([#1540](https://github.com/tldraw/tldraw/pull/1540))
- Fixed a rare crash that could happen when you try to curve an arrow with zero distance.
#### [2/3] renderer changes to support "sandwich mode" highlighting ([#1418](https://github.com/tldraw/tldraw/pull/1418))
[not yet!]
#### Measure individual words instead of just line breaks for text exports ([#1397](https://github.com/tldraw/tldraw/pull/1397))
- Add a brief release note for your PR here.
#### avoid lazy race conditions ([#1364](https://github.com/tldraw/tldraw/pull/1364))
[internal only]
---
#### 🚀 Enhancement
- [2/3] renderer changes to support "sandwich mode" highlighting [#1418](https://github.com/tldraw/tldraw/pull/1418) ([@SomeHats](https://github.com/SomeHats))
#### 🐛 Bug Fix
- [refactor] snapping [#1589](https://github.com/tldraw/tldraw/pull/1589) ([@steveruizok](https://github.com/steveruizok))
- Fix arrows with weird bends crashing [#1540](https://github.com/tldraw/tldraw/pull/1540) ([@TodePond](https://github.com/TodePond))
- ensure that fixed points stay fixed [#1523](https://github.com/tldraw/tldraw/pull/1523) ([@steveruizok](https://github.com/steveruizok))
- Measure individual words instead of just line breaks for text exports [#1397](https://github.com/tldraw/tldraw/pull/1397) ([@SomeHats](https://github.com/SomeHats))
- readmes [#1195](https://github.com/tldraw/tldraw/pull/1195) ([@steveruizok](https://github.com/steveruizok))
- [chore] update lazyrepo [#1211](https://github.com/tldraw/tldraw/pull/1211) ([@ds300](https://github.com/ds300))
- Use `strokePathData` for `<ShapeFill/>` path to avoid bugs in the inner path algo [#1207](https://github.com/tldraw/tldraw/pull/1207) ([@orangemug](https://github.com/orangemug) [@steveruizok](https://github.com/steveruizok))
- [lite] upgrade lazyrepo [#1198](https://github.com/tldraw/tldraw/pull/1198) ([@ds300](https://github.com/ds300))
- transfer-out: transfer out [#1195](https://github.com/tldraw/tldraw/pull/1195) ([@SomeHats](https://github.com/SomeHats))
#### ⚠️ Pushed to `main`
- update lazyrepo ([@ds300](https://github.com/ds300))
#### 🏠 Internal
- replace console.log with nicelog [#1496](https://github.com/tldraw/tldraw/pull/1496) ([@steveruizok](https://github.com/steveruizok))
- [chore] remove benchmark [#1489](https://github.com/tldraw/tldraw/pull/1489) ([@steveruizok](https://github.com/steveruizok))
- avoid lazy race conditions [#1364](https://github.com/tldraw/tldraw/pull/1364) ([@SomeHats](https://github.com/SomeHats))
#### Authors: 5
- alex ([@SomeHats](https://github.com/SomeHats))
- David Sheldrick ([@ds300](https://github.com/ds300))
- Lu Wilson ([@TodePond](https://github.com/TodePond))
- Orange Mug ([@orangemug](https://github.com/orangemug))
- Steve Ruiz ([@steveruizok](https://github.com/steveruizok))
---
# v2.0.0-alpha.12 (Mon Apr 03 2023)
#### 🐛 Bug Fix
- Make sure all types and build stuff get run in CI [#1548](https://github.com/tldraw/tldraw-lite/pull/1548) ([@SomeHats](https://github.com/SomeHats))
- add pre-commit api report generation [#1517](https://github.com/tldraw/tldraw-lite/pull/1517) ([@SomeHats](https://github.com/SomeHats))
- Fix back to content button. [#1519](https://github.com/tldraw/tldraw-lite/pull/1519) ([@MitjaBezensek](https://github.com/MitjaBezensek) [@steveruizok](https://github.com/steveruizok))
- [chore] restore api extractor [#1500](https://github.com/tldraw/tldraw-lite/pull/1500) ([@steveruizok](https://github.com/steveruizok))
- David/publish good [#1488](https://github.com/tldraw/tldraw-lite/pull/1488) ([@ds300](https://github.com/ds300))
- [chore] alpha 10 [#1486](https://github.com/tldraw/tldraw-lite/pull/1486) ([@ds300](https://github.com/ds300))
- [chore] package build improvements [#1484](https://github.com/tldraw/tldraw-lite/pull/1484) ([@ds300](https://github.com/ds300))
- [chore] bump for alpha 8 [#1485](https://github.com/tldraw/tldraw-lite/pull/1485) ([@steveruizok](https://github.com/steveruizok))
- stop using broken-af turbo for publishing [#1476](https://github.com/tldraw/tldraw-lite/pull/1476) ([@ds300](https://github.com/ds300))
- [chore] add canary release script [#1423](https://github.com/tldraw/tldraw-lite/pull/1423) ([@ds300](https://github.com/ds300) [@steveruizok](https://github.com/steveruizok))
- [chore] upgrade yarn [#1430](https://github.com/tldraw/tldraw-lite/pull/1430) ([@ds300](https://github.com/ds300))
- repo cleanup [#1426](https://github.com/tldraw/tldraw-lite/pull/1426) ([@steveruizok](https://github.com/steveruizok))
#### Authors: 4
- alex ([@SomeHats](https://github.com/SomeHats))
- David Sheldrick ([@ds300](https://github.com/ds300))
- Mitja Bezenšek ([@MitjaBezensek](https://github.com/MitjaBezensek))
- Steve Ruiz ([@steveruizok](https://github.com/steveruizok))
---
# @tldraw/primitives

@@ -2,0 +90,0 @@

90

dist-cjs/index.d.ts

@@ -24,5 +24,6 @@ import { Box2dModel } from '@tldraw/tlschema';

* Checks whether two angles are approximately at right-angles or parallel to each other
* @param a - angle a (radians)
* @param b - angle b (radians)
* @returns true iff the angles are approximately at right-angles or parallel to each other
*
* @param a - Angle a (radians)
* @param b - Angle b (radians)
* @returns True iff the angles are approximately at right-angles or parallel to each other
* @public

@@ -64,3 +65,4 @@ */

* A lookup table consisting of values.p points along the segment. Used to compute lengths,
* closest points, etc. This should only be _computed once (when first requested) per set of values.
* closest points, etc. This should only be _computed once (when first requested) per set of
* values.
*

@@ -170,3 +172,3 @@ * @public

addPoint(point: Vec2d): this;
removePoint(point: Vec2d | number): this;
removePoint(point: number | Vec2d): this;
getPointAtLength(length: number): Vec2d;

@@ -222,6 +224,7 @@ getPoint(t: number): Vec2d;

includes(B: Box2d): boolean;
containsPoint(V: VecLike | number, y?: number): boolean;
containsPoint(V: number | VecLike, y?: number): boolean;
getHandlePoint(handle: SelectionCorner | SelectionEdge): Vec2d;
toJson(): Box2dModel;
resize(handle: SelectionCorner | SelectionEdge | string, dx: number, dy: number): void;
union(box: Box2dModel): this;
static From(box: Box2dModel): Box2d;

@@ -234,3 +237,3 @@ static FromPoints(points: VecLike[]): Box2d;

static Includes: (A: Box2d, B: Box2d) => boolean;
static ContainsPoint: (A: Box2d, B: VecLike | number, y?: number) => boolean;
static ContainsPoint: (A: Box2d, B: number | VecLike, y?: number) => boolean;
static Common: (boxes: Box2d[]) => Box2d;

@@ -256,3 +259,5 @@ static Sides: (A: Box2d, inset?: number) => Vec2d[][];

* Clamp a value into a range.
*
* @example
*
* ```ts

@@ -272,2 +277,3 @@ * const A = clamp(0, 1) // 1

* @example
*
* ```ts

@@ -368,6 +374,6 @@ * const A = clamp(0, 1, 10) // 1

/** @public */
export declare function flipSelectionHandleX(handle: SelectionHandle): "top" | "right" | "bottom" | "left" | "top_left" | "top_right" | "bottom_right" | "bottom_left";
export declare function flipSelectionHandleX(handle: SelectionHandle): "bottom_left" | "bottom_right" | "bottom" | "left" | "right" | "top_left" | "top_right" | "top";
/** @public */
export declare function flipSelectionHandleY(handle: SelectionHandle): "top" | "right" | "bottom" | "left" | "top_left" | "top_right" | "bottom_right" | "bottom_left";
export declare function flipSelectionHandleY(handle: SelectionHandle): "bottom_left" | "bottom_right" | "bottom" | "left" | "right" | "top_left" | "top_right" | "top";

@@ -386,2 +392,5 @@ /**

/** @public */
export declare function getDrawLinePathData(id: string, outline: VecLike[], strokeWidth: number): string[];
/** @public */
export declare function getHeight(pts: VecLike[]): number;

@@ -421,8 +430,14 @@

/** @public */
export declare function getRoundedInkyPolygonPath(points: VecLike[]): string;
/** @public */
export declare function getRoundedPolygonPoints(id: string, outline: VecLike[], offset: number, roundness: number, passes: number): VecLike[];
/**
* Gets the width/height of a star given its input bounds.
*
* @param sides - number of sides
* @param w - t target width
* @param h - target height
* @param sides - Number of sides
* @param w - T target width
* @param h - Target height
* @returns Box2d

@@ -441,3 +456,2 @@ * @public

* @param options - An object with options.
*
* @public

@@ -454,3 +468,2 @@ */

* @param options - An object with options.
*
* @public

@@ -469,3 +482,2 @@ */

* @param options - An object with options.
*
* @public

@@ -507,3 +519,3 @@ */

*/
export declare function intersectCirclePolygon(c: VecLike, r: number, points: VecLike[]): VecLike[] | null;
export declare function intersectCirclePolygon(c: VecLike, r: number, points: VecLike[]): null | VecLike[];

@@ -518,3 +530,3 @@ /**

*/
export declare function intersectCirclePolyline(c: VecLike, r: number, points: VecLike[]): VecLike[] | null;
export declare function intersectCirclePolyline(c: VecLike, r: number, points: VecLike[]): null | VecLike[];

@@ -530,3 +542,3 @@ /**

*/
export declare function intersectLineSegmentCircle(a1: VecLike, a2: VecLike, c: VecLike, r: number): VecLike[] | null;
export declare function intersectLineSegmentCircle(a1: VecLike, a2: VecLike, c: VecLike, r: number): null | VecLike[];

@@ -540,6 +552,5 @@ /**

* @param b2 - The second segment's second point.
*
* @public
*/
export declare function intersectLineSegmentLineSegment(a1: VecLike, a2: VecLike, b1: VecLike, b2: VecLike): Vec2d | null;
export declare function intersectLineSegmentLineSegment(a1: VecLike, a2: VecLike, b1: VecLike, b2: VecLike): null | Vec2d;

@@ -554,3 +565,3 @@ /**

*/
export declare function intersectLineSegmentPolygon(a1: VecLike, a2: VecLike, points: VecLike[]): VecLike[] | null;
export declare function intersectLineSegmentPolygon(a1: VecLike, a2: VecLike, points: VecLike[]): null | VecLike[];

@@ -565,3 +576,3 @@ /**

*/
export declare function intersectLineSegmentPolyline(a1: VecLike, a2: VecLike, points: VecLike[]): VecLike[] | null;
export declare function intersectLineSegmentPolyline(a1: VecLike, a2: VecLike, points: VecLike[]): null | VecLike[];

@@ -573,3 +584,3 @@ /**

*/
export declare function intersectPolygonBounds(points: VecLike[], bounds: Box2d): VecLike[] | null;
export declare function intersectPolygonBounds(points: VecLike[], bounds: Box2d): null | VecLike[];

@@ -583,3 +594,3 @@ /**

*/
export declare function intersectPolygonPolygon(polygonA: VecLike[], polygonB: VecLike[]): VecLike[] | null;
export declare function intersectPolygonPolygon(polygonA: VecLike[], polygonB: VecLike[]): null | VecLike[];

@@ -596,2 +607,8 @@ /**

/**
* Check if a float is safe to use. ie: Not too big or small.
* @public
*/
export declare const isSafeFloat: (n: number) => boolean;
/** @public */

@@ -659,3 +676,3 @@ export declare function isSelectionCorner(selection: string): selection is SelectionCorner;

/** @public */
export declare type MatLike = Matrix2dModel | Matrix2d;
export declare type MatLike = Matrix2d | Matrix2dModel;

@@ -883,3 +900,3 @@ /** @public */

/** @public */
export declare type RotateCorner = 'top_left_rotate' | 'top_right_rotate' | 'bottom_right_rotate' | 'bottom_left_rotate' | 'mobile_rotate';
export declare type RotateCorner = 'bottom_left_rotate' | 'bottom_right_rotate' | 'mobile_rotate' | 'top_left_rotate' | 'top_right_rotate';

@@ -890,9 +907,9 @@ /** @public */

/** @public */
export declare type SelectionCorner = 'top_left' | 'top_right' | 'bottom_right' | 'bottom_left';
export declare type SelectionCorner = 'bottom_left' | 'bottom_right' | 'top_left' | 'top_right';
/** @public */
export declare type SelectionEdge = 'top' | 'right' | 'bottom' | 'left';
export declare type SelectionEdge = 'bottom' | 'left' | 'right' | 'top';
/** @public */
export declare type SelectionHandle = SelectionEdge | SelectionCorner;
export declare type SelectionHandle = SelectionCorner | SelectionEdge;

@@ -924,3 +941,3 @@ /** @public */

/**@public */
/** @public */
export declare const SIN: (x: number) => number;

@@ -947,3 +964,3 @@

thinning?: number;
/** How much to soften the stroke's edges. */
/** How much to soften the stroke's edges. */
smoothing?: number;

@@ -958,3 +975,3 @@ streamline?: number;

cap?: boolean;
taper?: number | boolean;
taper?: boolean | number;
easing?: (distance: number) => number;

@@ -965,3 +982,3 @@ };

cap?: boolean;
taper?: number | boolean;
taper?: boolean | number;
easing?: (distance: number) => number;

@@ -975,2 +992,3 @@ };

* The points returned by `getStrokePoints`, and the input for `getStrokeOutlinePoints`
*
* @public

@@ -993,2 +1011,3 @@ */

* The DOM likes values to be fixed to 3 decimal places
*
* @public

@@ -999,2 +1018,7 @@ */

/**
* @public
*/
export declare function toFixed(v: number): number;
/**
* Get a number to a precision.

@@ -1001,0 +1025,0 @@ *

@@ -6,2 +6,6 @@ "use strict";

var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {

@@ -15,7 +19,102 @@ if (from && typeof from === "object" || typeof from === "function") {

};
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var src_exports = {};
__export(src_exports, {
Box2d: () => import_Box2d.Box2d,
CubicSegment2d: () => import_CubicSegment2d.CubicSegment2d,
CubicSpline2d: () => import_CubicSpline2d.CubicSpline2d,
EASINGS: () => import_easings.EASINGS,
EPSILON: () => import_utils.EPSILON,
LineSegment2d: () => import_LineSegment2d.LineSegment2d,
Matrix2d: () => import_Matrix2d.Matrix2d,
PI: () => import_utils.PI,
PI2: () => import_utils.PI2,
Polyline2d: () => import_Polyline2d.Polyline2d,
ROTATE_CORNER_TO_SELECTION_CORNER: () => import_Box2d.ROTATE_CORNER_TO_SELECTION_CORNER,
SIN: () => import_utils.SIN,
TAU: () => import_utils.TAU,
Vec2d: () => import_Vec2d.Vec2d,
angleDelta: () => import_utils.angleDelta,
approximately: () => import_utils.approximately,
areAnglesCompatible: () => import_utils.areAnglesCompatible,
canolicalizeRotation: () => import_utils.canolicalizeRotation,
clamp: () => import_utils.clamp,
clampRadians: () => import_utils.clampRadians,
decomposeMatrix2d: () => import_Matrix2d.decomposeMatrix2d,
degreesToRadians: () => import_utils.degreesToRadians,
flipSelectionHandleX: () => import_Box2d.flipSelectionHandleX,
flipSelectionHandleY: () => import_Box2d.flipSelectionHandleY,
getArcLength: () => import_utils.getArcLength,
getDrawLinePathData: () => import_polygon_helpers.getDrawLinePathData,
getHeight: () => import_utils.getHeight,
getMaxX: () => import_utils.getMaxX,
getMaxY: () => import_utils.getMaxY,
getMidX: () => import_utils.getMidX,
getMidY: () => import_utils.getMidY,
getMinX: () => import_utils.getMinX,
getMinY: () => import_utils.getMinY,
getPointOnCircle: () => import_utils.getPointOnCircle,
getPolygonVertices: () => import_utils.getPolygonVertices,
getRoundedInkyPolygonPath: () => import_polygon_helpers.getRoundedInkyPolygonPath,
getRoundedPolygonPoints: () => import_polygon_helpers.getRoundedPolygonPoints,
getStarBounds: () => import_utils.getStarBounds,
getStroke: () => import_getStroke.getStroke,
getStrokeOutlinePoints: () => import_getStrokeOutlinePoints.getStrokeOutlinePoints,
getStrokePoints: () => import_getStrokePoints.getStrokePoints,
getSweep: () => import_utils.getSweep,
getWidth: () => import_utils.getWidth,
intersectCircleCircle: () => import_intersect.intersectCircleCircle,
intersectCirclePolygon: () => import_intersect.intersectCirclePolygon,
intersectCirclePolyline: () => import_intersect.intersectCirclePolyline,
intersectLineSegmentCircle: () => import_intersect.intersectLineSegmentCircle,
intersectLineSegmentLineSegment: () => import_intersect.intersectLineSegmentLineSegment,
intersectLineSegmentPolygon: () => import_intersect.intersectLineSegmentPolygon,
intersectLineSegmentPolyline: () => import_intersect.intersectLineSegmentPolyline,
intersectPolygonBounds: () => import_intersect.intersectPolygonBounds,
intersectPolygonPolygon: () => import_intersect.intersectPolygonPolygon,
isAngleBetween: () => import_utils.isAngleBetween,
isSafeFloat: () => import_utils.isSafeFloat,
isSelectionCorner: () => import_Box2d.isSelectionCorner,
lerpAngles: () => import_utils.lerpAngles,
linesIntersect: () => import_intersect.linesIntersect,
longAngleDist: () => import_utils.longAngleDist,
perimeterOfEllipse: () => import_utils.perimeterOfEllipse,
pointInBounds: () => import_utils.pointInBounds,
pointInCircle: () => import_utils.pointInCircle,
pointInEllipse: () => import_utils.pointInEllipse,
pointInPolygon: () => import_utils.pointInPolygon,
pointInPolyline: () => import_utils.pointInPolyline,
pointInRect: () => import_utils.pointInRect,
pointNearToLineSegment: () => import_utils.pointNearToLineSegment,
pointNearToPolyline: () => import_utils.pointNearToPolyline,
polygonsIntersect: () => import_intersect.polygonsIntersect,
radiansToDegrees: () => import_utils.radiansToDegrees,
rangeIntersection: () => import_utils.rangeIntersection,
rangesOverlap: () => import_utils.rangesOverlap,
rotateSelectionHandle: () => import_Box2d.rotateSelectionHandle,
setStrokePointRadii: () => import_setStrokePointRadii.setStrokePointRadii,
shortAngleDist: () => import_utils.shortAngleDist,
simplify: () => import_utils.simplify,
simplify2: () => import_utils.simplify2,
snapAngle: () => import_utils.snapAngle,
toDomPrecision: () => import_utils.toDomPrecision,
toFixed: () => import_utils.toFixed,
toPrecision: () => import_utils.toPrecision
});
module.exports = __toCommonJS(src_exports);
__reExport(src_exports, require("./lib"), module.exports);
var import_Box2d = require("./lib/Box2d");
var import_CubicSegment2d = require("./lib/CubicSegment2d");
var import_CubicSpline2d = require("./lib/CubicSpline2d");
var import_LineSegment2d = require("./lib/LineSegment2d");
var import_Matrix2d = require("./lib/Matrix2d");
var import_Polyline2d = require("./lib/Polyline2d");
var import_Vec2d = require("./lib/Vec2d");
var import_easings = require("./lib/easings");
var import_getStroke = require("./lib/freehand/getStroke");
var import_getStrokeOutlinePoints = require("./lib/freehand/getStrokeOutlinePoints");
var import_getStrokePoints = require("./lib/freehand/getStrokePoints");
var import_setStrokePointRadii = require("./lib/freehand/setStrokePointRadii");
var import_intersect = require("./lib/intersect");
var import_polygon_helpers = require("./lib/polygon-helpers");
var import_utils = require("./lib/utils");
//# sourceMappingURL=index.js.map

@@ -47,2 +47,3 @@ "use strict";

isAngleBetween: () => isAngleBetween,
isSafeFloat: () => isSafeFloat,
lerpAngles: () => lerpAngles,

@@ -67,2 +68,3 @@ longAngleDist: () => longAngleDist,

toDomPrecision: () => toDomPrecision,
toFixed: () => toFixed,
toPrecision: () => toPrecision

@@ -395,2 +397,8 @@ });

}
function toFixed(v) {
return +v.toFixed(2);
}
const isSafeFloat = (n) => {
return Math.abs(n) < Number.MAX_SAFE_INTEGER;
};
//# sourceMappingURL=utils.js.map
{
"name": "@tldraw/primitives",
"description": "A tiny little drawing app (primitives).",
"version": "2.0.0-canary.f687c9f64",
"version": "2.0.0-canary.f745781056d5",
"packageManager": "yarn@3.5.0",
"author": {

@@ -34,14 +35,13 @@ "name": "tldraw GB Ltd.",

"scripts": {
"test": "yarn run -T jest",
"test:coverage": "yarn run -T jest --coverage",
"build:types": "yarn run -T tsx ../../scripts/build-types.ts",
"build": "echo 'build should be run by turbo'",
"build:package": "yarn run -T tsx ../../scripts/build-package.ts",
"build:api": "yarn run -T tsx ../../scripts/build-api.ts",
"test": "lazy inherit",
"test-coverage": "lazy inherit",
"build": "yarn run -T tsx ../../scripts/build-package.ts",
"build-api": "yarn run -T tsx ../../scripts/build-api.ts",
"prepack": "yarn run -T tsx ../../scripts/prepack.ts",
"postpack": "../../scripts/postpack.sh",
"pack-tarball": "yarn pack",
"lint": "yarn run -T tsx ../../scripts/lint.ts"
},
"dependencies": {
"@tldraw/tlschema": "2.0.0-canary.f687c9f64"
"@tldraw/tlschema": "2.0.0-canary.f745781056d5"
},

@@ -57,2 +57,5 @@ "jest": {

},
"devDependencies": {
"lazyrepo": "0.0.0-alpha.27"
},
"module": "dist-esm/index.mjs",

@@ -59,0 +62,0 @@ "source": "src/index.ts",

# @tldraw/primitives
## License
The source code in this repository (as well as our 2.0+ distributions and releases) are currently licensed under Apache-2.0. These licenses are subject to change in our upcoming 2.0 release. If you are planning to use tldraw in a commercial product, please reach out at [hello@tldraw.com](mailto://hello@tldraw.com).

@@ -1,1 +0,98 @@

export * from './lib'
export {
Box2d,
ROTATE_CORNER_TO_SELECTION_CORNER,
flipSelectionHandleX,
flipSelectionHandleY,
isSelectionCorner,
rotateSelectionHandle,
type RotateCorner,
type SelectionCorner,
type SelectionEdge,
type SelectionHandle,
} from './lib/Box2d'
export { CubicSegment2d, type CubicSegment2dModel } from './lib/CubicSegment2d'
export { CubicSpline2d } from './lib/CubicSpline2d'
export { LineSegment2d, type LineSegment2dModel } from './lib/LineSegment2d'
export {
Matrix2d,
decomposeMatrix2d,
type MatLike,
type Matrix2dModel,
type MatrixInfo,
} from './lib/Matrix2d'
export { Polyline2d } from './lib/Polyline2d'
export { Vec2d, type VecLike } from './lib/Vec2d'
export { EASINGS, type EasingType } from './lib/easings'
export { getStroke } from './lib/freehand/getStroke'
export { getStrokeOutlinePoints } from './lib/freehand/getStrokeOutlinePoints'
export { getStrokePoints } from './lib/freehand/getStrokePoints'
export { setStrokePointRadii } from './lib/freehand/setStrokePointRadii'
export { type StrokeOptions, type StrokePoint } from './lib/freehand/types'
export {
intersectCircleCircle,
intersectCirclePolygon,
intersectCirclePolyline,
intersectLineSegmentCircle,
intersectLineSegmentLineSegment,
intersectLineSegmentPolygon,
intersectLineSegmentPolyline,
intersectPolygonBounds,
intersectPolygonPolygon,
linesIntersect,
polygonsIntersect,
} from './lib/intersect'
export {
getDrawLinePathData,
getRoundedInkyPolygonPath,
getRoundedPolygonPoints,
} from './lib/polygon-helpers'
export {
EPSILON,
PI,
PI2,
SIN,
TAU,
angleDelta,
approximately,
areAnglesCompatible,
canolicalizeRotation,
clamp,
clampRadians,
degreesToRadians,
getArcLength,
getHeight,
getMaxX,
getMaxY,
getMidX,
getMidY,
getMinX,
getMinY,
getPointOnCircle,
getPolygonVertices,
getStarBounds,
getSweep,
getWidth,
isAngleBetween,
isSafeFloat,
lerpAngles,
longAngleDist,
perimeterOfEllipse,
pointInBounds,
pointInCircle,
pointInEllipse,
pointInPolygon,
pointInPolyline,
pointInRect,
pointNearToLineSegment,
pointNearToPolyline,
radiansToDegrees,
rangeIntersection,
rangesOverlap,
shortAngleDist,
simplify,
simplify2,
snapAngle,
toDomPrecision,
toFixed,
toPrecision,
} from './lib/utils'

@@ -15,3 +15,2 @@ import { Vec2d, VecLike } from '../Vec2d'

* @param options - An object with options.
*
* @public

@@ -18,0 +17,0 @@ */

@@ -16,3 +16,2 @@ import { Vec2d } from '../Vec2d'

* @param options - An object with options.
*
* @public

@@ -109,4 +108,2 @@ */

// console.log(nextDpr)
if (nextDpr > -0.62 && totalLength - strokePoint.runningLength > strokePoint.radius) {

@@ -113,0 +110,0 @@ // Draw a "soft" corner

@@ -16,3 +16,2 @@ import { Vec2d, VecLike } from '../Vec2d'

* @param options - An object with options.
*
* @public

@@ -19,0 +18,0 @@ */

@@ -13,3 +13,3 @@ import { Vec2d } from '../Vec2d'

thinning?: number
/** How much to soften the stroke's edges. */
/** How much to soften the stroke's edges. */
smoothing?: number

@@ -39,2 +39,3 @@ streamline?: number

* The points returned by `getStrokePoints`, and the input for `getStrokeOutlinePoints`
*
* @public

@@ -41,0 +42,0 @@ */

@@ -14,3 +14,2 @@ import { Box2d } from './Box2d'

* @param b2 - The second segment's second point.
*
* @public

@@ -17,0 +16,0 @@ */

@@ -12,3 +12,3 @@ import { Box2d } from './Box2d'

export const EPSILON = Math.PI / 180
/**@public */
/** @public */
export const SIN = Math.sin

@@ -18,3 +18,5 @@

* Clamp a value into a range.
*
* @example
*
* ```ts

@@ -33,2 +35,3 @@ * const A = clamp(0, 1) // 1

* @example
*
* ```ts

@@ -187,5 +190,6 @@ * const A = clamp(0, 1, 10) // 1

* Checks whether two angles are approximately at right-angles or parallel to each other
* @param a - angle a (radians)
* @param b - angle b (radians)
* @returns true iff the angles are approximately at right-angles or parallel to each other
*
* @param a - Angle a (radians)
* @param b - Angle b (radians)
* @returns True iff the angles are approximately at right-angles or parallel to each other
* @public

@@ -311,5 +315,5 @@ */

*
* @param sides - number of sides
* @param w - t target width
* @param h - target height
* @param sides - Number of sides
* @param w - T target width
* @param h - Target height
* @returns Box2d

@@ -331,5 +335,3 @@ * @public

/**
* Helper for point in polygon
*/
/** Helper for point in polygon */
function cross(x: VecLike, y: VecLike, z: VecLike): number {

@@ -668,2 +670,3 @@ return (y.x - x.x) * (z.y - x.y) - (z.x - x.x) * (y.y - x.y)

* The DOM likes values to be fixed to 3 decimal places
*
* @public

@@ -674,1 +677,16 @@ */

}
/**
* @public
*/
export function toFixed(v: number) {
return +v.toFixed(2)
}
/**
* Check if a float is safe to use. ie: Not too big or small.
* @public
*/
export const isSafeFloat = (n: number) => {
return Math.abs(n) < Number.MAX_SAFE_INTEGER
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc