UNPKG

@thi.ng/geom

Version:

Functional, polymorphic API for 2D geometry types & SVG generation

18 lines (17 loc) 409 B
import { mixN } from "@thi.ng/vectors/mixn"; import { __pointArraysAsShapes } from "./points-as-shape.js"; import { clamp01 } from "@thi.ng/math/interval"; const __splitLineAt = ({ points: [a, b], attribs, constructor: ctor }, t = 0) => { const p = mixN([], a, b, clamp01(t)); return __pointArraysAsShapes( ctor, [ [a, p], [p, b] ], attribs ); }; export { __splitLineAt };