UNPKG

3.55 kBTypeScriptView Raw
1import { RenderingContext2D } from '../types';
2import PathParser from '../PathParser';
3import Document from './Document';
4import TextElement from './TextElement';
5import PathElement from './PathElement';
6export interface IPoint {
7 x: number;
8 y: number;
9}
10export interface IPathCommand {
11 command: string;
12 points: number[];
13 start?: IPoint;
14 pathLength: number;
15}
16interface ICachedPoint extends IPoint {
17 distance: number;
18}
19interface IGlyphInfo {
20 transposeX: number;
21 transposeY: number;
22 text: string;
23 rotation: number;
24 p0: ICachedPoint;
25 p1: ICachedPoint;
26}
27export default class TextPathElement extends TextElement {
28 type: string;
29 protected textWidth: number;
30 protected textHeight: number;
31 protected pathLength: number;
32 protected glyphInfo: IGlyphInfo[];
33 protected readonly text: string;
34 protected readonly dataArray: IPathCommand[];
35 private letterSpacingCache;
36 private equidistantCache;
37 private readonly measuresCache;
38 constructor(document: Document, node: HTMLElement, captureTextNodes?: boolean);
39 getText(): string;
40 path(ctx: RenderingContext2D): void;
41 renderChildren(ctx: RenderingContext2D): void;
42 protected getLetterSpacingAt(idx?: number): number;
43 protected findSegmentToFitChar(ctx: RenderingContext2D, anchor: string, textFullWidth: number, fullPathWidth: number, spacesNumber: number, inputOffset: number, c: string, charI: number): {
44 offset: number;
45 segment: {
46 p0: ICachedPoint;
47 p1: ICachedPoint;
48 };
49 };
50 protected measureText(ctx: RenderingContext2D, text?: string): number;
51 protected setTextData(ctx: RenderingContext2D): void;
52 protected parsePathData(path: PathElement): IPathCommand[];
53 protected pathM(pathParser: PathParser, points: number[]): string;
54 protected pathL(pathParser: PathParser, points: number[]): string;
55 protected pathH(pathParser: PathParser, points: number[]): string;
56 protected pathV(pathParser: PathParser, points: number[]): string;
57 protected pathC(pathParser: PathParser, points: number[]): void;
58 protected pathS(pathParser: PathParser, points: number[]): string;
59 protected pathQ(pathParser: PathParser, points: number[]): void;
60 protected pathT(pathParser: PathParser, points: number[]): string;
61 protected pathA(pathParser: PathParser): number[];
62 protected calcLength(x: number, y: number, cmd: string, points: number[]): number;
63 protected getPointOnLine(dist: number, P1x: number, P1y: number, P2x: number, P2y: number, fromX?: number, fromY?: number): IPoint;
64 protected getPointOnPath(distance: number): IPoint;
65 protected getLineLength(x1: number, y1: number, x2: number, y2: number): number;
66 protected getPathLength(): number;
67 protected getPointOnCubicBezier(pct: number, P1x: number, P1y: number, P2x: number, P2y: number, P3x: number, P3y: number, P4x: number, P4y: number): IPoint;
68 protected getPointOnQuadraticBezier(pct: number, P1x: number, P1y: number, P2x: number, P2y: number, P3x: number, P3y: number): IPoint;
69 protected getPointOnEllipticalArc(cx: number, cy: number, rx: number, ry: number, theta: number, psi: number): IPoint;
70 protected buildEquidistantCache(inputStep: number, inputPrecision: number): void;
71 protected getEquidistantPointOnPath(targetDistance: number, step?: number, precision?: number): ICachedPoint;
72}
73export {};
74//# sourceMappingURL=TextPathElement.d.ts.map
\No newline at end of file