UNPKG

svg-path-d

Version:

SVG path data (path[d] attribute content) manipulation library.

26 lines (25 loc) 1.62 kB
import { Rect } from './utils/math2d'; import { CurveTo, QCurveTo, SmoothCurveTo, SmoothQCurveTo } from './command'; import { PathNode } from './path-node'; export declare type CurveNode = PathNode & (CurveTo | QCurveTo | SmoothCurveTo | SmoothQCurveTo); export declare type SmoothCurveNode = PathNode & (SmoothCurveTo | SmoothQCurveTo); /** * The S/s and T/t commands indicate that the first control point of the given cubic/quadratic * Bézier curve is calculated by reflecting the previous path segment's final control point * relative to the current point. * * The exact math is as follows. * If the current point is (curx, cury) * and the final control point of the previous path segment is (oldx2, oldy2), * then the first control point of the current path segment (reflected point) is: * * (newx1, newy1) = (curx - (oldx2 - curx), cury - (oldy2 - cury)) = (2*curx - oldx2, 2*cury - oldy2) */ export declare function getReflectedX1(node: Readonly<SmoothCurveNode>): number; export declare function getReflectedY1(node: Readonly<SmoothCurveNode>): number; export declare function getFirstControlX(node: Readonly<CurveNode>): number; export declare function getFirstControlY(node: Readonly<CurveNode>): number; export declare function getLastControlX(node: Readonly<CurveNode>): number; export declare function getLastControlY(node: Readonly<CurveNode>): number; export declare function getQCurveBoundingRect(node: Readonly<PathNode & (QCurveTo | SmoothQCurveTo)>): Rect; export declare function getCurveBoundingRect(node: Readonly<PathNode & (CurveTo | SmoothCurveTo)>): Rect;