Skip to content
pixi-silk
GitHub repository
Function

nearestOnCubic

import { nearestOnCubic } from 'pixi-silk/path';
function nearestOnCubic(c: Cubic, p: Vec): {
  distance: number;
  t: number;
  x: number;
  y: number;
};

The closest point of a cubic to p. It takes 33 samples and refines around the best one, so it can pick the wrong part of a curve that passes almost equally close twice.

Parameters#

ParameterType
cCubic
pVec

Returns#

{
  distance: number;
  t: number;
  x: number;
  y: number;
}
NameTypeDefined in
distancenumberpath.ts:159
tnumberpath.ts:159
xnumberpath.ts:159
ynumberpath.ts:159