From e7dfe86a394283420377cdf2db99a412f1b4bf06 Mon Sep 17 00:00:00 2001 From: kyechan99 Date: Thu, 18 Jul 2024 18:59:33 +0900 Subject: [PATCH] fix: specify return type Path.getPoint static methods --- src/shapes/Path.ts | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/src/shapes/Path.ts b/src/shapes/Path.ts index e91f5400..d860b853 100644 --- a/src/shapes/Path.ts +++ b/src/shapes/Path.ts @@ -2,7 +2,7 @@ import { Factory } from '../Factory'; import { Shape, ShapeConfig } from '../Shape'; import { _registerNode } from '../Global'; -import { GetSet, PathSegment } from '../types'; +import { GetSet, PathSegment, Vector2d } from '../types'; import { getCubicArcLength, getQuadraticArcLength, @@ -235,7 +235,10 @@ export class Path extends Shape { return pathLength; } - static getPointAtLengthOfDataArray(length: number, dataArray) { + static getPointAtLengthOfDataArray( + length: number, + dataArray + ): Vector2d | null { var point, i = 0, ii = dataArray.length; @@ -319,7 +322,7 @@ export class Path extends Shape { return null; } - static getPointOnLine(dist, P1x, P1y, P2x, P2y, fromX?, fromY?) { + static getPointOnLine(dist, P1x, P1y, P2x, P2y, fromX?, fromY?): Vector2d { fromX = fromX ?? P1x; fromY = fromY ?? P1y; @@ -354,7 +357,17 @@ export class Path extends Shape { return { x: ix + adjustedRun, y: iy + adjustedRise }; } - static getPointOnCubicBezier(pct, P1x, P1y, P2x, P2y, P3x, P3y, P4x, P4y) { + static getPointOnCubicBezier( + pct, + P1x, + P1y, + P2x, + P2y, + P3x, + P3y, + P4x, + P4y + ): Vector2d { function CB1(t) { return t * t * t; } @@ -375,7 +388,15 @@ export class Path extends Shape { y: y, }; } - static getPointOnQuadraticBezier(pct, P1x, P1y, P2x, P2y, P3x, P3y) { + static getPointOnQuadraticBezier( + pct, + P1x, + P1y, + P2x, + P2y, + P3x, + P3y + ): Vector2d { function QB1(t) { return t * t; }