Skip to content

Commit

Permalink
fix: specify return type Path.getPoint static methods
Browse files Browse the repository at this point in the history
  • Loading branch information
kyechan99 committed Jul 18, 2024
1 parent ffc58d2 commit e7dfe86
Showing 1 changed file with 26 additions and 5 deletions.
31 changes: 26 additions & 5 deletions src/shapes/Path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -235,7 +235,10 @@ export class Path extends Shape<PathConfig> {
return pathLength;
}

static getPointAtLengthOfDataArray(length: number, dataArray) {
static getPointAtLengthOfDataArray(
length: number,
dataArray
): Vector2d | null {
var point,
i = 0,
ii = dataArray.length;
Expand Down Expand Up @@ -319,7 +322,7 @@ export class Path extends Shape<PathConfig> {
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;

Expand Down Expand Up @@ -354,7 +357,17 @@ export class Path extends Shape<PathConfig> {
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;
}
Expand All @@ -375,7 +388,15 @@ export class Path extends Shape<PathConfig> {
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;
}
Expand Down

0 comments on commit e7dfe86

Please sign in to comment.