1.7.2, add Vec.distanceTo / Vec.nearestPointOnBounds

pull/734/head
Steve Ruiz 2022-06-21 08:49:45 +01:00
rodzic 7c0e098b12
commit a17bd18ae2
7 zmienionych plików z 58 dodań i 3 usunięć

Wyświetl plik

@ -1,5 +1,11 @@
## 1.2.4
## 1.16.1
### Patch Changes
- Fix clipboard bug in Firefox, add overwite option to `insertContent`.
## 1.16.0
### Minor Changes

Wyświetl plik

@ -2,7 +2,7 @@
"name": "tldraw-vscode",
"displayName": "tldraw",
"description": "The tldraw Extension for VS Code.",
"version": "1.16.0",
"version": "1.16.1",
"license": "MIT",
"publisher": "tldraw-org",
"repository": {

Wyświetl plik

@ -1,5 +1,12 @@
# @tldraw/www
## 1.7.2
### Patch Changes
- Updated dependencies
- @tldraw/tldraw@1.17.1
## 1.7.1
### Patch Changes

Wyświetl plik

@ -1,6 +1,6 @@
{
"name": "@tldraw/www",
"version": "1.7.1",
"version": "1.7.2",
"private": true,
"description": "A tiny little drawing app (site).",
"repository": {

Wyświetl plik

@ -1,5 +1,11 @@
# Changelog
## 1.17.1
### Patch Changes
- Fix clipboard bug in Firefox, add overwite option to `insertContent`.
## 1.17.0
### Minor Changes

Wyświetl plik

@ -1,6 +1,6 @@
{
"name": "@tldraw/tldraw",
"version": "1.17.0",
"version": "1.17.1",
"description": "A tiny little drawing app (editor)",
"author": "@steveruizok",
"repository": {

Wyświetl plik

@ -449,6 +449,42 @@ export class Vec {
return Vec.dist(P, Vec.nearestPointOnLineSegment(A, B, P, clamp))
}
/**
* Get the nearest point on a bounding box to a point P.
* @param bounds The bounding box
* @param P The point point
* @returns
*/
static nearestPointOnBounds = (
bounds: {
minX: number
minY: number
maxX: number
maxY: number
},
P: number[]
): number[] => {
return [Vec.clamp(P[0], bounds.minX, bounds.maxX), Vec.clamp(P[1], bounds.minY, bounds.maxY)]
}
/**
* Distance between a point and the nearest point on a bounding box.
* @param bounds The bounding box.
* @param P The point
* @returns
*/
static distanceToBounds = (
bounds: {
minX: number
minY: number
maxX: number
maxY: number
},
P: number[]
): number => {
return Vec.dist(P, Vec.nearestPointOnBounds(bounds, P))
}
/**
* Push a point A towards point B by a given distance.
* @param A