@0x2e757/math-ext 中文文档教程

发布于 6年前 浏览 29 项目主页 更新于 3年前

MathExt

具有有用数学函数的库,例如带有参数和简单几何类的 clamprandom。 图书馆主要面向与任何类型的简单图形一起使用。 类对象也支持链接。

转译为 ES3 JavaScript 的 TypeScript 代码。

Install

npm i @0x2e757/math-ext

Usage

How to import

import { ... } from "@0x2e757/math-ext";

Interfaces

interface IRange {
    start: number;
    end: number;
}
interface IPoint {
    x: number;
    y: number;
    z: number;
}
interface IRect {
    left: number;
    top: number;
    right: number;
    bottom: number;
}

Math functions

```打字稿 clamp = (value: number, min: number, max: number) => 数字 clamp = (value: number, range: IRange) => 数字


打字稿 round = (value: number, fractionDigits: number) => 数字


打字稿 random = (min: number, max: number) => 数字 random = (min: number, max: number, integer: boolean) => 数字 随机 = (范围: IRange) => 数字 random = (range: IRange, integer: boolean) => 数字

### Range methods

打字稿 新范围(开始:数字,结束:数字)=> 范围 新范围(范围:IRange)=> 范围


打字稿 shift = (offset: number) => 范围 shift = (offsetStart: 数字, offsetEnd: 数字) => 范围


打字稿 乘法=(乘数:数字)=> 范围 multiply = (multiplierStart: 数字, multiplierEnd: 数字) => 范围


打字稿 clamp = (min: number, max: number) => 范围 clamp = (minStart: number, maxStart: number, minEnd: number, maxEnd: number) => 范围 clamp =(范围:IRange)=> 范围 clamp = (rangeStart: IRange, rangeEnd: IRange) => 范围 clampStart = (min: number, max: number) => 范围 clampStart =(范围:IRange)=> 范围 clampEnd = (min: number, max: number) => 范围 clampEnd =(范围:IRange)=> 范围


打字稿 round = (fractionDigits: number) => 范围 round = (fractionDigitsStart: number, fractionDigitsEnd: number) => 范围 roundStart = (fractionDigits: number) => 范围 roundEnd = (fractionDigits: number) => 范围


打字稿 归一化 = () => 范围


打字稿 包含 =(值:数字)=> 布尔值 包含=(范围:IRange)=> 布尔

### Point methods

打字稿 新点()=> 观点 新点(x:数字)=> 观点 新点(x:数字,y:数字)=> 观点 新点(x:数字,y:数字,z:数字)=> 观点 新点(点:IPoint)=> 点


打字稿 shift = (offsetX: 数字) => 观点 shift = (offsetX: 数字, offsetY: 数字) => 观点 shift = (offsetX: number, offsetY: number, offsetZ: number) => 观点 shift = (point: IPoint) => 观点 shiftX =(偏移量:数字)=> 观点 shiftY =(偏移量:数字)=> 观点 shiftZ = (offset: number) => 点


打字稿 乘法 = (multiplierX: number) => 观点 multiply = (multiplierX: 数字, multiplierY: 数字) => 观点 multiply = (multiplierX: 数字, multiplierY: 数字, multiplierZ: 数字) => 观点 multiplyX =(乘数:数字)=> 观点 multiplyY = (multiplier: number) => 观点 multiplyZ = (multiplier: number) => 点


打字稿 clamp = (min: number, max: number) => 观点 clamp = (minX: number, maxX: number, minY: number, maxY: number, minZ: number, maxZ: number) => 观点 钳位=(范围:IRange)=> 观点 钳位 = (rangeX: IRange, rangeY: IRange, rangeZ: IRange) => 观点 clampX = (min: number, max: number) => 观点 clampX =(范围:IRange)=> 观点 clampY = (min: number, max: number) => 观点 clampY = (范围: IRange) => 观点 clampZ = (min: number, max: number) => 观点 clampZ = (范围: IRange) => 点


打字稿 round = (fractionDigits: number) => 观点 round = (fractionDigitsX: number, fractionDigitsY: number, fractionDigitsZ: number) => 观点 roundX = (fractionDigits: number) => 观点 roundY = (fractionDigits: number) => 观点 roundZ = (fractionDigits: number) => 点


打字稿 距离=(点:IPoint)=> 数字

### Rect methods

打字稿 新矩形()=> 长方形 new Rect(left: number, top: number, right: number, bottom: number) => 长方形 新矩形(左上角:IPoint,右下角:IPoint)=> 长方形 新矩形(矩形:IRect)=> 矩形


打字稿 shift = (offsetHorizo​​ntal: number, offsetVertical: number) => 长方形 shift = (offsetLeft: number, offsetTop: number, offsetRight: number, offsetBottom: number) => 长方形 shift = (offset: IPoint) => 长方形 shiftLeft =(偏移量:数字)=> 长方形 shiftTop =(偏移量:数字)=> 长方形 shiftRight =(偏移量:数字)=> 长方形 shiftBottom =(偏移量:数字)=> 长方形 shiftHorizo​​ntal = (offset: number) => 长方形 shiftHorizo​​ntal = (offsetLeft: number, offsetRight: number) => 长方形 shiftVertical =(偏移量:数字)=> 长方形 shiftVertical = (offsetTop: 数字, offsetBottom: 数字) => 长方形 shiftTopLeft =(偏移量:IPoint)=> 长方形 shiftTopLeft = (offsetLeft: 数字, offsetTop: 数字) => 长方形 shiftTopRight =(偏移量:IPoint)=> 长方形 shiftTopRight = (offsetRight: 数字, offsetTop: 数字) => 长方形 shiftBottomLeft =(偏移量:IPoint)=> 长方形 shiftBottomLeft = (offsetLeft: 数字, offsetBottom: 数字) => 长方形 shiftBottomRight =(偏移量:IPoint)=> 长方形 shiftBottomRight = (offsetRight: 数字, offsetBottom: 数字) => 矩形


打字稿 乘法=(乘数:数字)=> 长方形 multiply = (multiplierHorizo​​ntal: number, multiplierVertical: number) => 长方形 multiplyHorizo​​ntal = (multiplier: number) => 长方形 multiplyVertical = (multiplier: number) => 矩形


打字稿 clamp = (min: number, max: number) => 长方形 clamp = (minHorizo​​ntal: number, maxHorizo​​ntal: number, minVertical: number, maxVertical: number) => 长方形 clamp = (minLeft: number, maxLeft: number, minTop: number, maxTop: number, minRight: number, maxRight: number, minBottom: number, maxBottom: number) => 长方形 钳位=(矩形:IRect)=> 长方形 钳位 = (rangeHorizo​​ntal: IRange, rangeVertical: IRange) => 长方形 clamp = (rangeLeft: IRange, rangeTop: IRange, rangeRight: IRange, rangeBottom: IRange) => 长方形 clampLeft = (min: number, max: number) => 长方形 clampLeft = (范围: IRange) => 长方形 clampTop = (min: number, max: number) => 长方形 clampTop =(范围:IRange)=> 长方形 clampRight = (min: number, max: number) => 长方形 clampRight =(范围:IRange)=> 长方形 clampBottom = (min: number, max: number) => 长方形 clampBottom =(范围:IRange)=> 长方形 clampHorizo​​ntal = (min: number, max: number) => 长方形 clampHorizo​​ntal =(范围:IRange)=> 长方形 clampVertical = (min: number, max: number) => 长方形 clampVertical =(范围:IRange)=> 长方形 clampTopLeft = (min: number, max: number) => 长方形 clampTopLeft =(范围:IRange)=> 长方形 clampTopRight = (min: number, max: number) => 长方形 clampTopRight =(范围:IRange)=> 长方形 clampBottomLeft = (min: number, max: number) => 长方形 clampBottomLeft =(范围:IRange)=> 长方形 clampBottomRight = (min: number, max: number) => 长方形 clampBottomRight =(范围:IRange)=> 矩形


打字稿 round = (fractionDigits: number) => 长方形 round = (fractionDigitsHorizo​​ntal: number, fractionDigitsVertical: number) => 长方形 roundHorizo​​ntal = (fractionDigits: number) => 长方形 roundVertical = (fractionDigits: number) => 矩形


打字稿 归一化 = () => 矩形


打字稿 左上角 = () => 积分 topLeft = (left: number, top: number) => 长方形 topLeft = (topLeft: IPoint) => 矩形


打字稿 右上角 = () => 积分 topRight = (right: number, top: number) => 长方形 topRight = (topRight: IPoint) => 矩形


打字稿 底部左 = () => 积分 bottomLeft = (left: number, bottom: number) => 长方形 bottomLeft = (bottomLeft: IPoint) => 矩形


打字稿 右下角 = () => 积分 bottomRight =(右:数字,底部:数字)=> 长方形 bottomRight = (bottomRight: IPoint) => 矩形


打字稿 宽度 = () => 数字 宽度=(宽度:数字)=> 矩形


打字稿 高度 = () => 数字 高度 = (高度: 数字) => 矩形


打字稿 包含=(点:IPoint)=> 布尔值 包含 = (rect: IRect) => 布尔值 ```

MathExt

Library with useful math functions like clamp and random with parameters and simple geometry classes. Library mostly oriented to be used with any kind of simple graphics. Also class objects support chaining.

TypeScript code transpiled to ES3 JavaScript.

Install

npm i @0x2e757/math-ext

Usage

How to import

import { ... } from "@0x2e757/math-ext";

Interfaces

interface IRange {
    start: number;
    end: number;
}
interface IPoint {
    x: number;
    y: number;
    z: number;
}
interface IRect {
    left: number;
    top: number;
    right: number;
    bottom: number;
}

Math functions

```typescript clamp = (value: number, min: number, max: number) => number clamp = (value: number, range: IRange) => number


typescript round = (value: number, fractionDigits: number) => number


typescript random = (min: number, max: number) => number random = (min: number, max: number, integer: boolean) => number random = (range: IRange) => number random = (range: IRange, integer: boolean) => number

### Range methods

typescript new Range(start: number, end: number) => Range new Range(range: IRange) => Range


typescript shift = (offset: number) => Range shift = (offsetStart: number, offsetEnd: number) => Range


typescript multiply = (multiplier: number) => Range multiply = (multiplierStart: number, multiplierEnd: number) => Range


typescript clamp = (min: number, max: number) => Range clamp = (minStart: number, maxStart: number, minEnd: number, maxEnd: number) => Range clamp = (range: IRange) => Range clamp = (rangeStart: IRange, rangeEnd: IRange) => Range clampStart = (min: number, max: number) => Range clampStart = (range: IRange) => Range clampEnd = (min: number, max: number) => Range clampEnd = (range: IRange) => Range


typescript round = (fractionDigits: number) => Range round = (fractionDigitsStart: number, fractionDigitsEnd: number) => Range roundStart = (fractionDigits: number) => Range roundEnd = (fractionDigits: number) => Range


typescript normalize = () => Range


typescript contains = (value: number) => boolean contains = (range: IRange) => boolean

### Point methods

typescript new Point() => Point new Point(x: number) => Point new Point(x: number, y: number) => Point new Point(x: number, y: number, z: number) => Point new Point(point: IPoint) => Point


typescript shift = (offsetX: number) => Point shift = (offsetX: number, offsetY: number) => Point shift = (offsetX: number, offsetY: number, offsetZ: number) => Point shift = (point: IPoint) => Point shiftX = (offset: number) => Point shiftY = (offset: number) => Point shiftZ = (offset: number) => Point


typescript multiply = (multiplierX: number) => Point multiply = (multiplierX: number, multiplierY: number) => Point multiply = (multiplierX: number, multiplierY: number, multiplierZ: number) => Point multiplyX = (multiplier: number) => Point multiplyY = (multiplier: number) => Point multiplyZ = (multiplier: number) => Point


typescript clamp = (min: number, max: number) => Point clamp = (minX: number, maxX: number, minY: number, maxY: number, minZ: number, maxZ: number) => Point clamp = (range: IRange) => Point clamp = (rangeX: IRange, rangeY: IRange, rangeZ: IRange) => Point clampX = (min: number, max: number) => Point clampX = (range: IRange) => Point clampY = (min: number, max: number) => Point clampY = (range: IRange) => Point clampZ = (min: number, max: number) => Point clampZ = (range: IRange) => Point


typescript round = (fractionDigits: number) => Point round = (fractionDigitsX: number, fractionDigitsY: number, fractionDigitsZ: number) => Point roundX = (fractionDigits: number) => Point roundY = (fractionDigits: number) => Point roundZ = (fractionDigits: number) => Point


typescript distance = (point: IPoint) => number

### Rect methods

typescript new Rect() => Rect new Rect(left: number, top: number, right: number, bottom: number) => Rect new Rect(topLeft: IPoint, bottomRight: IPoint) => Rect new Rect(rect: IRect) => Rect


typescript shift = (offsetHorizontal: number, offsetVertical: number) => Rect shift = (offsetLeft: number, offsetTop: number, offsetRight: number, offsetBottom: number) => Rect shift = (offset: IPoint) => Rect shiftLeft = (offset: number) => Rect shiftTop = (offset: number) => Rect shiftRight = (offset: number) => Rect shiftBottom = (offset: number) => Rect shiftHorizontal = (offset: number) => Rect shiftHorizontal = (offsetLeft: number, offsetRight: number) => Rect shiftVertical = (offset: number) => Rect shiftVertical = (offsetTop: number, offsetBottom: number) => Rect shiftTopLeft = (offset: IPoint) => Rect shiftTopLeft = (offsetLeft: number, offsetTop: number) => Rect shiftTopRight = (offset: IPoint) => Rect shiftTopRight = (offsetRight: number, offsetTop: number) => Rect shiftBottomLeft = (offset: IPoint) => Rect shiftBottomLeft = (offsetLeft: number, offsetBottom: number) => Rect shiftBottomRight = (offset: IPoint) => Rect shiftBottomRight = (offsetRight: number, offsetBottom: number) => Rect


typescript multiply = (multiplier: number) => Rect multiply = (multiplierHorizontal: number, multiplierVertical: number) => Rect multiplyHorizontal = (multiplier: number) => Rect multiplyVertical = (multiplier: number) => Rect


typescript clamp = (min: number, max: number) => Rect clamp = (minHorizontal: number, maxHorizontal: number, minVertical: number, maxVertical: number) => Rect clamp = (minLeft: number, maxLeft: number, minTop: number, maxTop: number, minRight: number, maxRight: number, minBottom: number, maxBottom: number) => Rect clamp = (rect: IRect) => Rect clamp = (rangeHorizontal: IRange, rangeVertical: IRange) => Rect clamp = (rangeLeft: IRange, rangeTop: IRange, rangeRight: IRange, rangeBottom: IRange) => Rect clampLeft = (min: number, max: number) => Rect clampLeft = (range: IRange) => Rect clampTop = (min: number, max: number) => Rect clampTop = (range: IRange) => Rect clampRight = (min: number, max: number) => Rect clampRight = (range: IRange) => Rect clampBottom = (min: number, max: number) => Rect clampBottom = (range: IRange) => Rect clampHorizontal = (min: number, max: number) => Rect clampHorizontal = (range: IRange) => Rect clampVertical = (min: number, max: number) => Rect clampVertical = (range: IRange) => Rect clampTopLeft = (min: number, max: number) => Rect clampTopLeft = (range: IRange) => Rect clampTopRight = (min: number, max: number) => Rect clampTopRight = (range: IRange) => Rect clampBottomLeft = (min: number, max: number) => Rect clampBottomLeft = (range: IRange) => Rect clampBottomRight = (min: number, max: number) => Rect clampBottomRight = (range: IRange) => Rect


typescript round = (fractionDigits: number) => Rect round = (fractionDigitsHorizontal: number, fractionDigitsVertical: number) => Rect roundHorizontal = (fractionDigits: number) => Rect roundVertical = (fractionDigits: number) => Rect


typescript normalize = () => Rect


typescript topLeft = () => IPoint topLeft = (left: number, top: number) => Rect topLeft = (topLeft: IPoint) => Rect


typescript topRight = () => IPoint topRight = (right: number, top: number) => Rect topRight = (topRight: IPoint) => Rect


typescript bottomLeft = () => IPoint bottomLeft = (left: number, bottom: number) => Rect bottomLeft = (bottomLeft: IPoint) => Rect


typescript bottomRight = () => IPoint bottomRight = (right: number, bottom: number) => Rect bottomRight = (bottomRight: IPoint) => Rect


typescript width = () => number width = (width: number) => Rect


typescript height = () => number height = (height: number) => Rect


typescript contains = (point: IPoint) => boolean contains = (rect: IRect) => boolean ```

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文