AI-native design editor. Open-source Figma alternative.
import type { Vector } from './primitives'
/** The point at `t` along the cubic from `p0` to `p3` with control points `p1` and `p2`. */
export function cubicPoint(p0: Vector, p1: Vector, p2: Vector, p3: Vector, t: number): Vector {
const u = 1 - t
const a = u * u * u
const b = 3 * u * u * t
const c = 3 * u * t * t
const d = t * t * t
return {
x: a * p0.x + b * p1.x + c * p2.x + d * p3.x,
y: a * p0.y + b * p1.y + c * p2.y + d * p3.y
}
}