From cbc0b7252127995470023986e6eb92724b90cecc Mon Sep 17 00:00:00 2001 From: Baku Hashimoto Date: Wed, 21 Feb 2024 14:18:01 +0900 Subject: [PATCH] Add Line.trim --- src/Line.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/Line.ts b/src/Line.ts index e3d3050..93c50d8 100644 --- a/src/Line.ts +++ b/src/Line.ts @@ -46,6 +46,20 @@ export namespace Line { return [...xAxis, ...yAxis, ...p] } + export function trim( + line: SimpleSegmentL, + start: SegmentLocation, + end: SegmentLocation + ): SegmentL { + const startTime = toTime(line, start) + const endTime = toTime(line, end) + + const newStart = point(line, startTime) + const newEnd = point(line, endTime) + + return {start: newStart, point: newEnd, command: 'L'} + } + export function divideAtTimes( line: SimpleSegmentL, times: number[]