Clean up @excalidraw/math a bit
This commit is contained in:
parent
02b4fa1ca7
commit
83abf2cd94
@ -1,4 +1,14 @@
|
|||||||
# @excalidraw/math
|
# @excalidraw/math - 2D Vector Graphics Math Library
|
||||||
|
The package contains a collection of (mostly) independent functions providing
|
||||||
|
the mathematical basis for Excalidraw's rendering, hit detection, bounds
|
||||||
|
checking and anything using math underneath.
|
||||||
|
|
||||||
|
The philosophy of the library is to be self-contained and therefore there is no
|
||||||
|
dependency on any other package. It only contains pure functions. It also
|
||||||
|
prefers analytical solutions vs numberical wherever possible. Since this
|
||||||
|
library is used in a high performance context, we might chose to use a numerical
|
||||||
|
approximation, even if an analytical solution is available to preserve
|
||||||
|
performance.
|
||||||
|
|
||||||
## Install
|
## Install
|
||||||
|
|
||||||
|
3
packages/math/global.d.ts
vendored
3
packages/math/global.d.ts
vendored
@ -1,3 +0,0 @@
|
|||||||
/// <reference types="vite/client" />
|
|
||||||
import "@excalidraw/excalidraw/global";
|
|
||||||
import "@excalidraw/excalidraw/css";
|
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@excalidraw/math",
|
"name": "@excalidraw/math",
|
||||||
"version": "0.1.0",
|
"version": "0.2.0",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"types": "./dist/types/math/src/index.d.ts",
|
"types": "./dist/types/math/src/index.d.ts",
|
||||||
"main": "./dist/prod/index.js",
|
"main": "./dist/prod/index.js",
|
||||||
@ -19,7 +19,7 @@
|
|||||||
"files": [
|
"files": [
|
||||||
"dist/*"
|
"dist/*"
|
||||||
],
|
],
|
||||||
"description": "Excalidraw math functions",
|
"description": "Excalidraw math library for 2D vector graphics.",
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"access": "public"
|
"access": "public"
|
||||||
},
|
},
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { PRECISION } from "./utils";
|
import { PRECISION } from "./constants";
|
||||||
|
|
||||||
import type {
|
import type {
|
||||||
Degrees,
|
Degrees,
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
export const PRECISION = 10e-5;
|
||||||
|
|
||||||
// Legendre-Gauss abscissae (x values) and weights for n=24
|
// Legendre-Gauss abscissae (x values) and weights for n=24
|
||||||
// Refeerence: https://pomax.github.io/bezierinfo/legendre-gauss.html
|
// Refeerence: https://pomax.github.io/bezierinfo/legendre-gauss.html
|
||||||
export const LegendreGaussN24TValues = [
|
export const LegendreGaussN24TValues = [
|
||||||
|
@ -4,7 +4,7 @@ import {
|
|||||||
pointFromVector,
|
pointFromVector,
|
||||||
pointsEqual,
|
pointsEqual,
|
||||||
} from "./point";
|
} from "./point";
|
||||||
import { PRECISION } from "./utils";
|
import { PRECISION } from "./constants";
|
||||||
import {
|
import {
|
||||||
vector,
|
vector,
|
||||||
vectorAdd,
|
vectorAdd,
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { degreesToRadians } from "./angle";
|
import { degreesToRadians } from "./angle";
|
||||||
import { PRECISION } from "./utils";
|
import { PRECISION } from "./constants";
|
||||||
import { vectorFromPoint, vectorScale } from "./vector";
|
import { vectorFromPoint, vectorScale } from "./vector";
|
||||||
|
|
||||||
import type {
|
import type {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { pointsEqual } from "./point";
|
import { pointsEqual } from "./point";
|
||||||
import { lineSegment, pointOnLineSegment } from "./segment";
|
import { lineSegment, pointOnLineSegment } from "./segment";
|
||||||
import { PRECISION } from "./utils";
|
import { PRECISION } from "./constants";
|
||||||
|
|
||||||
import type { GlobalPoint, LocalPoint, Polygon } from "./types";
|
import type { GlobalPoint, LocalPoint, Polygon } from "./types";
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ import {
|
|||||||
pointFromVector,
|
pointFromVector,
|
||||||
pointRotateRads,
|
pointRotateRads,
|
||||||
} from "./point";
|
} from "./point";
|
||||||
import { PRECISION } from "./utils";
|
import { PRECISION } from "./constants";
|
||||||
import {
|
import {
|
||||||
vectorAdd,
|
vectorAdd,
|
||||||
vectorCross,
|
vectorCross,
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
export const PRECISION = 10e-5;
|
import { PRECISION } from "./constants";
|
||||||
|
|
||||||
export const clamp = (value: number, min: number, max: number) => {
|
export const clamp = (value: number, min: number, max: number) => {
|
||||||
return Math.min(Math.max(value, min), max);
|
return Math.min(Math.max(value, min), max);
|
||||||
|
@ -3,6 +3,6 @@
|
|||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"outDir": "./dist/types"
|
"outDir": "./dist/types"
|
||||||
},
|
},
|
||||||
"include": ["src/**/*", "global.d.ts"],
|
"include": ["src/**/*"],
|
||||||
"exclude": ["**/*.test.*", "tests", "types", "examples", "dist"]
|
"exclude": ["**/*.test.*", "tests", "types", "examples", "dist"]
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user