aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2024-05-01 09:47:11 -0400
committerbobzel <zzzman@gmail.com>2024-05-01 09:47:11 -0400
commit76838b7b3842c9b184e6459e29796dd14de37e8d (patch)
treef96cc6db69e72e90179e8b1c3003401146ee3522 /src
parent098deaa68c8b9bb781748fbe0c1bd0104bab3596 (diff)
more cycle import removal. fixed ndollar bugs introduced during lint changes.
Diffstat (limited to 'src')
-rw-r--r--src/client/documents/DocUtils.ts6
-rw-r--r--src/client/util/CurrentUserUtils.ts6
-rw-r--r--src/client/util/LinkFollower.ts4
-rw-r--r--src/client/views/MarqueeAnnotator.tsx3
-rw-r--r--src/client/views/collections/CollectionStackedTimeline.tsx7
-rw-r--r--src/client/views/global/globalEnums.tsx5
-rw-r--r--src/client/views/global/globalScripts.ts4
-rw-r--r--src/client/views/nodes/DocumentContentsView.tsx2
-rw-r--r--src/client/views/nodes/DocumentView.tsx4
-rw-r--r--src/client/views/nodes/FontIconBox/FontIconBox.tsx30
-rw-r--r--src/client/views/nodes/VideoBox.tsx7
-rw-r--r--src/fields/ScriptField.ts4
-rw-r--r--src/pen-gestures/ndollar.ts12
13 files changed, 50 insertions, 44 deletions
diff --git a/src/client/documents/DocUtils.ts b/src/client/documents/DocUtils.ts
index e93bbc41b..0a47e0359 100644
--- a/src/client/documents/DocUtils.ts
+++ b/src/client/documents/DocUtils.ts
@@ -16,7 +16,7 @@ import { InkDataFieldName, InkField } from '../../fields/InkField';
import { List, ListFieldName } from '../../fields/List';
import { ProxyField } from '../../fields/Proxy';
import { RichTextField } from '../../fields/RichTextField';
-import { ComputedField, FollowLinkScript, ScriptField } from '../../fields/ScriptField';
+import { ComputedField, ScriptField } from '../../fields/ScriptField';
import { BoolCast, Cast, DocCast, FieldValue, NumCast, ScriptCast, StrCast } from '../../fields/Types';
import { AudioField, CsvField, ImageField, PdfField, VideoField, WebField } from '../../fields/URLField';
import { SharingPermissions } from '../../fields/util';
@@ -864,6 +864,10 @@ export namespace DocUtils {
}
}
+export function FollowLinkScript() {
+ return ScriptField.MakeScript('return followLink(this,altKey)', { altKey: 'boolean' });
+}
+
ScriptingGlobals.add('Docs', Docs);
// eslint-disable-next-line prefer-arrow-callback
ScriptingGlobals.add(function copyDragFactory(dragFactory: Doc, asDelegate?: boolean) {
diff --git a/src/client/util/CurrentUserUtils.ts b/src/client/util/CurrentUserUtils.ts
index 96f5172bc..15c8fec5a 100644
--- a/src/client/util/CurrentUserUtils.ts
+++ b/src/client/util/CurrentUserUtils.ts
@@ -8,13 +8,13 @@ import { List } from "../../fields/List";
import { PrefetchProxy } from "../../fields/Proxy";
import { RichTextField } from "../../fields/RichTextField";
import { listSpec } from "../../fields/Schema";
-import { FollowLinkScript, ScriptField } from "../../fields/ScriptField";
+import { ScriptField } from "../../fields/ScriptField";
import { Cast, DateCast, DocCast, StrCast } from "../../fields/Types";
import { WebField, nullAudio } from "../../fields/URLField";
import { SetCachedGroups, SharingPermissions } from "../../fields/util";
import { Gestures } from "../../pen-gestures/GestureTypes";
import { DocServer } from "../DocServer";
-import { DocUtils } from '../documents/DocUtils';
+import { DocUtils, FollowLinkScript } from '../documents/DocUtils';
import { CollectionViewType, DocumentType } from "../documents/DocumentTypes";
import { Docs, DocumentOptions, FInfo, FInfoFieldType } from "../documents/Documents";
import { DashboardView } from "../views/DashboardView";
@@ -730,7 +730,7 @@ pie title Minerals in my tap water
CollectionViewType.Multirow, CollectionViewType.Time, CollectionViewType.Carousel,
CollectionViewType.Carousel3D, CollectionViewType.Linear, CollectionViewType.Map,
CollectionViewType.Grid, CollectionViewType.NoteTaking]),
- title: "Perspective", toolTip: "View", btnType: ButtonType.DropdownList, ignoreClick: true, width: 100, scripts: { script: 'setView(value, _readOnly_)'}},
+ title: "Perspective", toolTip: "View", btnType: ButtonType.DropdownList, ignoreClick: true, width: 100, scripts: { script: '{ return setView(value, _readOnly_); }'}},
{ title: "Pin", icon: "map-pin", toolTip: "Pin View to Trail", btnType: ButtonType.ClickButton, expertMode: false, width: 30, scripts: { onClick: 'pinWithView(altKey)'}, funcs: {hidden: "IsNoneSelected()"}},
{ title: "Header", icon: "heading", toolTip: "Doc Titlebar Color", btnType: ButtonType.ColorButton, expertMode: false, ignoreClick: true, scripts: { script: 'return setHeaderColor(value, _readOnly_)'} },
{ title: "Template",icon: "scroll", toolTip: "Default Note Template",btnType: ButtonType.ToggleButton, expertMode: false, toolType:DocumentType.RTF, scripts: { onClick: '{ return setDefaultTemplate(_readOnly_); }'} },
diff --git a/src/client/util/LinkFollower.ts b/src/client/util/LinkFollower.ts
index 7ab476591..a6f6122ab 100644
--- a/src/client/util/LinkFollower.ts
+++ b/src/client/util/LinkFollower.ts
@@ -4,6 +4,7 @@ import { BoolCast, Cast, DocCast, NumCast, ScriptCast, StrCast } from '../../fie
import { DocumentType } from '../documents/DocumentTypes';
import { FocusViewOptions } from '../views/nodes/FocusViewOptions';
import { OpenWhere } from '../views/nodes/OpenWhere';
+import { PresBox } from '../views/nodes/trails';
import { DocumentManager } from './DocumentManager';
import { LinkManager } from './LinkManager';
import { ScriptingGlobals } from './ScriptingGlobals';
@@ -89,8 +90,7 @@ export class LinkFollower {
const containerDocContext = DocumentManager.GetContextPath(sourceDoc, true); // gather all views that affect layout of sourceDoc so we can revert them after playing the rail
SelectionManager.DeselectAll();
if (!DocumentManager.Instance.AddViewRenderedCb(target, dv => containerDocContext.length && dv.ComponentView?.playTrail?.(containerDocContext))) {
- alert('OPEN Pres minimized');
- // PresBox.OpenPresMinimized(target, [0, 0]);
+ PresBox.OpenPresMinimized(target, [0, 0]);
}
finished?.();
} else {
diff --git a/src/client/views/MarqueeAnnotator.tsx b/src/client/views/MarqueeAnnotator.tsx
index 06cae6d04..0f13de9e5 100644
--- a/src/client/views/MarqueeAnnotator.tsx
+++ b/src/client/views/MarqueeAnnotator.tsx
@@ -4,12 +4,11 @@ import * as React from 'react';
import { Doc, Opt } from '../../fields/Doc';
import { AclAdmin, AclAugment, AclEdit, AclSelfEdit, DocData } from '../../fields/DocSymbols';
import { List } from '../../fields/List';
-import { FollowLinkScript } from '../../fields/ScriptField';
import { NumCast } from '../../fields/Types';
import { GetEffectiveAcl } from '../../fields/util';
import { unimplementedFunction, Utils } from '../../Utils';
import { Docs } from '../documents/Documents';
-import { DocUtils } from '../documents/DocUtils';
+import { DocUtils, FollowLinkScript } from '../documents/DocUtils';
import { DragManager } from '../util/DragManager';
import { undoable, undoBatch, UndoManager } from '../util/UndoManager';
import './MarqueeAnnotator.scss';
diff --git a/src/client/views/collections/CollectionStackedTimeline.tsx b/src/client/views/collections/CollectionStackedTimeline.tsx
index 50a66aa41..48d24c910 100644
--- a/src/client/views/collections/CollectionStackedTimeline.tsx
+++ b/src/client/views/collections/CollectionStackedTimeline.tsx
@@ -13,12 +13,13 @@ import { DocData } from '../../../fields/DocSymbols';
import { Id } from '../../../fields/FieldSymbols';
import { List } from '../../../fields/List';
import { listSpec } from '../../../fields/Schema';
-import { ComputedField, FollowLinkScript, ScriptField } from '../../../fields/ScriptField';
+import { ComputedField, ScriptField } from '../../../fields/ScriptField';
import { Cast, NumCast } from '../../../fields/Types';
import { ImageField } from '../../../fields/URLField';
import { emptyFunction, formatTime } from '../../../Utils';
import { Docs } from '../../documents/Documents';
import { DocumentType } from '../../documents/DocumentTypes';
+import { FollowLinkScript } from '../../documents/DocUtils';
import { DocumentManager } from '../../util/DocumentManager';
import { DragManager } from '../../util/DragManager';
import { IsFollowLinkScript, LinkFollower } from '../../util/LinkFollower';
@@ -27,6 +28,7 @@ import { ScriptingGlobals } from '../../util/ScriptingGlobals';
import { SnappingManager } from '../../util/SnappingManager';
import { Transform } from '../../util/Transform';
import { undoBatch, UndoManager } from '../../util/UndoManager';
+import { VideoThumbnails } from '../global/globalEnums';
import { LightboxView } from '../LightboxView';
import { AudioWaveform } from '../nodes/audio/AudioWaveform';
import { DocumentView } from '../nodes/DocumentView';
@@ -34,7 +36,6 @@ import { FocusFuncType, StyleProviderFuncType } from '../nodes/FieldView';
import { FocusViewOptions } from '../nodes/FocusViewOptions';
import { LabelBox } from '../nodes/LabelBox';
import { OpenWhere } from '../nodes/OpenWhere';
-import { VideoBox } from '../nodes/VideoBox';
import { ObservableReactComponent } from '../ObservableReactComponent';
import './CollectionStackedTimeline.scss';
import { CollectionSubView } from './CollectionSubView';
@@ -327,7 +328,7 @@ export class CollectionStackedTimeline extends CollectionSubView<CollectionStack
if (rect) {
this._hoverTime = this.toTimeline(clientX - rect.x, rect.width);
if (this.thumbnails) {
- const nearest = Math.floor((this._hoverTime / this._props.rawDuration) * VideoBox.numThumbnails);
+ const nearest = Math.floor((this._hoverTime / this._props.rawDuration) * VideoThumbnails.DENSE);
const imgField = this.thumbnails.length > 0 ? new ImageField(this.thumbnails[nearest]) : undefined;
this._thumbnail = imgField?.url?.href ? imgField.url.href.replace('.png', '_m.png') : undefined;
}
diff --git a/src/client/views/global/globalEnums.tsx b/src/client/views/global/globalEnums.tsx
index 2cf9e4162..46caa3702 100644
--- a/src/client/views/global/globalEnums.tsx
+++ b/src/client/views/global/globalEnums.tsx
@@ -42,3 +42,8 @@ export enum Borders {
export enum Shadows {
STANDARD_SHADOW = '0px 3px 4px rgba(0, 0, 0, 0.3)',
}
+
+export enum VideoThumbnails {
+ DENSE = 20,
+ SPARSE = 5,
+}
diff --git a/src/client/views/global/globalScripts.ts b/src/client/views/global/globalScripts.ts
index d17d4ff7c..e75b01ab6 100644
--- a/src/client/views/global/globalScripts.ts
+++ b/src/client/views/global/globalScripts.ts
@@ -31,9 +31,11 @@ ScriptingGlobals.add(function IsNoneSelected() {
// toggle: Set overlay status of selected document
// eslint-disable-next-line prefer-arrow-callback
-ScriptingGlobals.add(function setView(view: string) {
+ScriptingGlobals.add(function setView(view: string, getSelected: boolean) {
+ if (getSelected) return SelectionManager.Docs;
const selected = SelectionManager.Docs.lastElement();
selected ? (selected._type_collection = view) : console.log('[FontIconBox.tsx] changeView failed');
+ return undefined;
});
// toggle: Set overlay status of selected document
diff --git a/src/client/views/nodes/DocumentContentsView.tsx b/src/client/views/nodes/DocumentContentsView.tsx
index cc4b5b67f..e902d1792 100644
--- a/src/client/views/nodes/DocumentContentsView.tsx
+++ b/src/client/views/nodes/DocumentContentsView.tsx
@@ -19,7 +19,6 @@ import { CollectionView } from '../collections/CollectionView';
import { CollectionFreeFormView } from '../collections/collectionFreeForm/CollectionFreeFormView';
import { CollectionSchemaView } from '../collections/collectionSchema/CollectionSchemaView';
import { SchemaRowBox } from '../collections/collectionSchema/SchemaRowBox';
-import { PresElementBox } from './trails/PresElementBox';
import { SearchBox } from '../search/SearchBox';
import { AudioBox } from './AudioBox';
import { ComparisonBox } from './ComparisonBox';
@@ -47,6 +46,7 @@ import { WebBox } from './WebBox';
import { FormattedTextBox } from './formattedText/FormattedTextBox';
import { ImportElementBox } from './importBox/ImportElementBox';
import { PresBox } from './trails/PresBox';
+import { PresElementBox } from './trails/PresElementBox';
type BindingProps = Without<FieldViewProps, 'fieldKey'>;
export interface JsxBindings {
diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx
index e8d1e582e..1e7f1015a 100644
--- a/src/client/views/nodes/DocumentView.tsx
+++ b/src/client/views/nodes/DocumentView.tsx
@@ -16,13 +16,13 @@ import { InkTool } from '../../../fields/InkField';
import { List } from '../../../fields/List';
import { PrefetchProxy } from '../../../fields/Proxy';
import { listSpec } from '../../../fields/Schema';
-import { FollowLinkScript, ScriptField } from '../../../fields/ScriptField';
+import { ScriptField } from '../../../fields/ScriptField';
import { BoolCast, Cast, DocCast, NumCast, ScriptCast, StrCast } from '../../../fields/Types';
import { AudioField } from '../../../fields/URLField';
import { GetEffectiveAcl, TraceMobx } from '../../../fields/util';
import { DocServer } from '../../DocServer';
import { Networking } from '../../Network';
-import { DocUtils } from '../../documents/DocUtils';
+import { DocUtils, FollowLinkScript } from '../../documents/DocUtils';
import { CollectionViewType, DocumentType } from '../../documents/DocumentTypes';
import { Docs } from '../../documents/Documents';
import { DictationManager } from '../../util/DictationManager';
diff --git a/src/client/views/nodes/FontIconBox/FontIconBox.tsx b/src/client/views/nodes/FontIconBox/FontIconBox.tsx
index d83690cdd..8d1617e66 100644
--- a/src/client/views/nodes/FontIconBox/FontIconBox.tsx
+++ b/src/client/views/nodes/FontIconBox/FontIconBox.tsx
@@ -11,8 +11,7 @@ import { BoolCast, DocCast, NumCast, ScriptCast, StrCast } from '../../../../fie
import { emptyFunction } from '../../../../Utils';
import { Docs } from '../../../documents/Documents';
import { CollectionViewType, DocumentType } from '../../../documents/DocumentTypes';
-import { SelectionManager } from '../../../util/SelectionManager';
-import { SettingsManager } from '../../../util/SettingsManager';
+import { SnappingManager } from '../../../util/SnappingManager';
import { undoable, UndoManager } from '../../../util/UndoManager';
import { ContextMenu } from '../../ContextMenu';
import { ViewBoxBaseComponent } from '../../DocComponent';
@@ -125,7 +124,7 @@ export class FontIconBox extends ViewBoxBaseComponent<ButtonProps>() {
return (
<NumberDropdown
color={color}
- background={SettingsManager.userBackgroundColor}
+ background={SnappingManager.userBackgroundColor}
numberDropdownType={type}
showPlusMinus={false}
tooltip={this.label}
@@ -160,9 +159,10 @@ export class FontIconBox extends ViewBoxBaseComponent<ButtonProps>() {
let text: string | undefined;
let getStyle: (val: string) => any = () => {};
let icon: IconProp = 'caret-down';
- const isViewDropdown = script?.script.originalScript.startsWith('setView');
+ const isViewDropdown = script?.script.originalScript.startsWith('{ return setView');
if (isViewDropdown) {
- const selected = SelectionManager.Docs;
+ const selected = Array.from(script?.script.run({ _readOnly_: true }).result) as Doc[];
+ // const selected = SelectionManager.Docs;
if (selected.lastElement()) {
if (StrCast(selected.lastElement().type) === DocumentType.COL) {
text = StrCast(selected.lastElement()._type_collection);
@@ -178,15 +178,15 @@ export class FontIconBox extends ViewBoxBaseComponent<ButtonProps>() {
icon={<FontAwesomeIcon size="1x" icon={icon} />}
text={text}
type={Type.TERT}
- color={SettingsManager.userColor}
- background={SettingsManager.userVariantColor}
+ color={SnappingManager.userColor}
+ background={SnappingManager.userVariantColor}
popup={<SelectedDocView selectedDocs={selected} />}
fillWidth
/>
);
}
} else {
- return <Button text="None Selected" type={Type.TERT} color={SettingsManager.userColor} background={SettingsManager.userVariantColor} fillWidth inactive />;
+ return <Button text="None Selected" type={Type.TERT} color={SnappingManager.userColor} background={SnappingManager.userVariantColor} fillWidth inactive />;
}
noviceList = [CollectionViewType.Freeform, CollectionViewType.Schema, CollectionViewType.Carousel3D, CollectionViewType.Stacking, CollectionViewType.NoteTaking];
} else {
@@ -209,8 +209,8 @@ export class FontIconBox extends ViewBoxBaseComponent<ButtonProps>() {
<Dropdown
selectedVal={text}
setSelectedVal={undoable(value => script.script.run({ this: this.Document, self: this.Document, value }), `dropdown select ${this.label}`)}
- color={SettingsManager.userColor}
- background={SettingsManager.userVariantColor}
+ color={SnappingManager.userColor}
+ background={SnappingManager.userVariantColor}
type={Type.TERT}
closeOnSelect={false}
dropdownType={DropdownType.SELECT}
@@ -250,7 +250,7 @@ export class FontIconBox extends ViewBoxBaseComponent<ButtonProps>() {
selectedColor={curColor}
type={Type.PRIM}
color={color}
- background={SettingsManager.userBackgroundColor}
+ background={SnappingManager.userBackgroundColor}
icon={this.Icon(color)!}
tooltip={tooltip}
label={this.label}
@@ -271,7 +271,7 @@ export class FontIconBox extends ViewBoxBaseComponent<ButtonProps>() {
tooltip={`Toggle ${tooltip}`}
type={Type.PRIM}
color={color}
- background={SettingsManager.userBackgroundColor}
+ background={SnappingManager.userBackgroundColor}
label={this.label}
items={DocListCast(this.dataDoc.data).map(item => ({
icon: <FontAwesomeIcon className={`fontIconBox-icon-${this.type}`} icon={StrCast(item.icon) as any} color={color} />,
@@ -309,7 +309,7 @@ export class FontIconBox extends ViewBoxBaseComponent<ButtonProps>() {
toggleStatus={toggleStatus}
text={buttonText}
color={color}
- // background={SettingsManager.userBackgroundColor}
+ // background={SnappingManager.userBackgroundColor}
icon={this.Icon(color)!}
label={this.label}
onPointerDown={e =>
@@ -373,9 +373,9 @@ export class FontIconBox extends ViewBoxBaseComponent<ButtonProps>() {
case ButtonType.ClickButton:return <IconButton {...btnProps} size={Size.MEDIUM} color={color} />;
case ButtonType.ToolButton: return <IconButton {...btnProps} size={Size.LARGE} color={color} />;
case ButtonType.TextButton: return <Button {...btnProps} color={color}
- background={SettingsManager.userBackgroundColor} text={StrCast(this.dataDoc.buttonText)}/>;
+ background={SnappingManager.userBackgroundColor} text={StrCast(this.dataDoc.buttonText)}/>;
case ButtonType.MenuButton: return <IconButton {...btnProps} color={color}
- background={SettingsManager.userBackgroundColor} size={Size.LARGE} tooltipPlacement='right' onPointerDown={scriptFunc} />;
+ background={SnappingManager.userBackgroundColor} size={Size.LARGE} tooltipPlacement='right' onPointerDown={scriptFunc} />;
default:
}
return this.defaultButton;
diff --git a/src/client/views/nodes/VideoBox.tsx b/src/client/views/nodes/VideoBox.tsx
index 16767d11e..f32d00386 100644
--- a/src/client/views/nodes/VideoBox.tsx
+++ b/src/client/views/nodes/VideoBox.tsx
@@ -10,13 +10,12 @@ import { DocData } from '../../../fields/DocSymbols';
import { InkTool } from '../../../fields/InkField';
import { List } from '../../../fields/List';
import { ObjectField } from '../../../fields/ObjectField';
-import { FollowLinkScript } from '../../../fields/ScriptField';
import { Cast, NumCast, StrCast, toList } from '../../../fields/Types';
import { AudioField, ImageField, VideoField } from '../../../fields/URLField';
import { emptyFunction, formatTime } from '../../../Utils';
import { Docs } from '../../documents/Documents';
import { DocumentType } from '../../documents/DocumentTypes';
-import { DocUtils } from '../../documents/DocUtils';
+import { DocUtils, FollowLinkScript } from '../../documents/DocUtils';
import { DocumentManager } from '../../util/DocumentManager';
import { dropActionType } from '../../util/DropActionTypes';
import { LinkManager } from '../../util/LinkManager';
@@ -36,6 +35,7 @@ import { FieldView, FieldViewProps } from './FieldView';
import { FocusViewOptions } from './FocusViewOptions';
import { RecordingBox } from './RecordingBox';
import './VideoBox.scss';
+import { VideoThumbnails } from '../global/globalEnums';
/**
* VideoBox
@@ -55,7 +55,6 @@ export class VideoBox extends ViewBoxAnnotatableComponent<FieldViewProps>() impl
return FieldView.LayoutString(VideoBox, fieldKey);
}
static heightPercent = 80; // height of video relative to videoBox when timeline is open
- static numThumbnails = 20;
private unmounting = false;
private _disposers: { [name: string]: IReactionDisposer } = {};
private _videoRef: HTMLVideoElement | null = null; // <video> ref
@@ -416,7 +415,7 @@ export class VideoBox extends ViewBoxAnnotatableComponent<FieldViewProps>() impl
const retitled = StrCast(this.Document.title).replace(/[ -.:]/g, '');
const encodedFilename = encodeURIComponent('thumbnail' + retitled + '_' + video.currentTime.toString().replace(/\./, '_'));
thumbnailPromises?.push(ClientUtils.convertDataUri(canvas.toDataURL(), basename(encodedFilename), true));
- const newTime = video.currentTime + video.duration / (VideoBox.numThumbnails - 1);
+ const newTime = video.currentTime + video.duration / (VideoThumbnails.DENSE - 1);
if (newTime < video.duration) {
video.currentTime = newTime;
} else {
diff --git a/src/fields/ScriptField.ts b/src/fields/ScriptField.ts
index 5e5f5527f..8a3787768 100644
--- a/src/fields/ScriptField.ts
+++ b/src/fields/ScriptField.ts
@@ -277,10 +277,6 @@ export class ComputedField extends ScriptField {
}
}
-export function FollowLinkScript() {
- return ScriptField.MakeScript('return followLink(this,altKey)', { altKey: 'boolean' });
-}
-
ScriptingGlobals.add(
// eslint-disable-next-line prefer-arrow-callback
function setIndexVal(list: any[], index: number, value: any) {
diff --git a/src/pen-gestures/ndollar.ts b/src/pen-gestures/ndollar.ts
index bdb79b446..ff7f7310b 100644
--- a/src/pen-gestures/ndollar.ts
+++ b/src/pen-gestures/ndollar.ts
@@ -463,7 +463,7 @@ function ScaleDimTo(points: any, size: any, ratio1D: any) {
const B = BoundingBox(points);
const uniformly = Math.min(B.Width / B.Height, B.Height / B.Width) <= ratio1D; // 1D or 2D gesture test
const newpoints: Point[] = [];
- points.forEach((X: any, Y: any) => {
+ points.forEach(({ X, Y }) => {
const qx = uniformly ? X * (size / Math.max(B.Width, B.Height)) : X * (size / B.Width);
const qy = uniformly ? Y * (size / Math.max(B.Width, B.Height)) : Y * (size / B.Height);
newpoints[newpoints.length] = new Point(qx, qy);
@@ -474,7 +474,7 @@ function TranslateTo(points: any, pt: any) {
// translates points' centroid
const c = Centroid(points);
const newpoints: Point[] = [];
- points.forEach((X: any, Y: any) => {
+ points.forEach(({ X, Y }) => {
const qx = X + pt.X - c.X;
const qy = Y + pt.Y - c.Y;
newpoints[newpoints.length] = new Point(qx, qy);
@@ -548,9 +548,9 @@ function DistanceAtAngle(points: any, T: any, radians: any) {
function Centroid(points: Point[]) {
let x = 0.0;
let y = 0.0;
- points.forEach(point => {
- x += point.X;
- y += point.Y;
+ points.forEach(({ X, Y }) => {
+ x += X;
+ y += Y;
});
x /= points.length;
y /= points.length;
@@ -561,7 +561,7 @@ function BoundingBox(points: Point[]) {
let maxX = -Infinity;
let minY = +Infinity;
let maxY = -Infinity;
- points.forEach((X: any, Y: any) => {
+ points.forEach(({ X, Y }) => {
minX = Math.min(minX, X);
minY = Math.min(minY, Y);
maxX = Math.max(maxX, X);