V1_commit_RGC

This commit is contained in:
2026-02-11 13:57:54 +01:00
commit ef397eedac
4901 changed files with 292881 additions and 0 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,43 @@
import { TransformableSVG } from "./TransformableSVG";
import { SVGCommand } from "./types";
export declare class SVGPathData extends TransformableSVG {
commands: SVGCommand[];
constructor(content: string | SVGCommand[]);
encode(): string;
getBounds(): import("./types").TransformFunction & {
minX: number;
maxX: number;
minY: number;
maxY: number;
};
transform(transformFunction: (input: SVGCommand) => SVGCommand | SVGCommand[]): this;
static encode(commands: SVGCommand[]): string;
static parse(path: string): SVGCommand[];
static readonly CLOSE_PATH: 1;
static readonly MOVE_TO: 2;
static readonly HORIZ_LINE_TO: 4;
static readonly VERT_LINE_TO: 8;
static readonly LINE_TO: 16;
static readonly CURVE_TO: 32;
static readonly SMOOTH_CURVE_TO: 64;
static readonly QUAD_TO: 128;
static readonly SMOOTH_QUAD_TO: 256;
static readonly ARC: 512;
static readonly LINE_COMMANDS: number;
static readonly DRAWING_COMMANDS: number;
}
export declare const COMMAND_ARG_COUNTS: {
2: number;
16: number;
4: number;
8: number;
1: number;
128: number;
256: number;
32: number;
64: number;
512: number;
};
export { encodeSVGPath } from "./SVGPathDataEncoder";
export { SVGPathDataParser } from "./SVGPathDataParser";
export { SVGPathDataTransformer } from "./SVGPathDataTransformer";

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,2 @@
import { SVGCommand } from "./types";
export declare function encodeSVGPath(commands: SVGCommand | SVGCommand[]): string;

View File

@@ -0,0 +1,19 @@
import { TransformableSVG } from "./TransformableSVG";
import { SVGCommand, TransformFunction } from "./types";
export declare class SVGPathDataParser extends TransformableSVG {
private curNumber;
private curCommandType;
private curCommandRelative;
private canParseCommandOrComma;
private curNumberHasExp;
private curNumberHasExpDigits;
private curNumberHasDecimal;
private curArgs;
constructor();
finish(commands?: SVGCommand[]): SVGCommand[];
parse(str: string, commands?: SVGCommand[]): SVGCommand[];
/**
* Return a wrapper around this parser which applies the transformation on parsed commands.
*/
transform(transform: TransformFunction): this;
}

View File

@@ -0,0 +1,28 @@
import { SVGCommand, TransformFunction } from "./types";
export declare namespace SVGPathDataTransformer {
function ROUND(roundVal?: number): (command: any) => any;
function TO_ABS(): (command: any) => any;
function TO_REL(): (command: any) => any;
function NORMALIZE_HVZ(normalizeZ?: boolean, normalizeH?: boolean, normalizeV?: boolean): (command: any) => any;
function NORMALIZE_ST(): (command: any) => any;
function QT_TO_C(): (command: any) => any;
function INFO(f: (command: any, prevXAbs: number, prevYAbs: number, pathStartXAbs: number, pathStartYAbs: number) => any | any[]): (command: any) => any;
function SANITIZE(EPS?: number): (command: any) => any;
function MATRIX(a: number, b: number, c: number, d: number, e: number, f: number): (command: any) => any;
function ROTATE(a: number, x?: number, y?: number): (command: any) => any;
function TRANSLATE(dX: number, dY?: number): (command: any) => any;
function SCALE(dX: number, dY?: number): (command: any) => any;
function SKEW_X(a: number): (command: any) => any;
function SKEW_Y(a: number): (command: any) => any;
function X_AXIS_SYMMETRY(xOffset?: number): (command: any) => any;
function Y_AXIS_SYMMETRY(yOffset?: number): (command: any) => any;
function A_TO_C(): (command: any) => any;
function ANNOTATE_ARCS(): (command: any) => any;
function CLONE(): (c: SVGCommand) => SVGCommand;
function CALCULATE_BOUNDS(): TransformFunction & {
minX: number;
maxX: number;
minY: number;
maxY: number;
};
}

View File

@@ -0,0 +1,21 @@
import { TransformFunction } from "./types";
export declare abstract class TransformableSVG {
round(x?: number): this;
toAbs(): this;
toRel(): this;
normalizeHVZ(a?: boolean, b?: boolean, c?: boolean): this;
normalizeST(): this;
qtToC(): this;
aToC(): this;
sanitize(eps?: number): this;
translate(x: number, y?: number): this;
scale(x: number, y?: number): this;
rotate(a: number, x?: number, y?: number): this;
matrix(a: number, b: number, c: number, d: number, e: number, f: number): this;
skewX(a: number): this;
skewY(a: number): this;
xSymmetry(xOffset?: number): this;
ySymmetry(yOffset?: number): this;
annotateArcs(): this;
abstract transform(transformFunction: TransformFunction): this;
}

View File

@@ -0,0 +1,28 @@
import { CommandA, CommandC } from "./types";
export declare function rotate([x, y]: [number, number], rad: number): number[];
export declare function assertNumbers(...numbers: number[]): boolean;
/**
* https://www.w3.org/TR/SVG/implnote.html#ArcImplementationNotes
* Fixes rX and rY.
* Ensures lArcFlag and sweepFlag are 0 or 1
* Adds center coordinates: command.cX, command.cY (relative or absolute, depending on command.relative)
* Adds start and end arc parameters (in degrees): command.phi1, command.phi2; phi1 < phi2 iff. c.sweepFlag == true
*/
export declare function annotateArcCommand(c: CommandA, x1: number, y1: number): void;
/**
* Solves a quadratic system of equations of the form
* a * x + b * y = c
* x² + y² = 1
* This can be understood as the intersection of the unit circle with a line.
* => y = (c - a x) / b
* => x² + (c - a x)² / b² = 1
* => x² b² + c² - 2 c a x + a² x² = b²
* => (a² + b²) x² - 2 a c x + (c² - b²) = 0
*/
export declare function intersectionUnitCircleLine(a: number, b: number, c: number): [number, number][];
export declare const DEG: number;
export declare function lerp(a: number, b: number, t: number): number;
export declare function arcAt(c: number, x1: number, x2: number, phiDeg: number): number;
export declare function bezierRoot(x0: number, x1: number, x2: number, x3: number): number[];
export declare function bezierAt(x0: number, x1: number, x2: number, x3: number, t: number): number;
export declare function a2c(arc: CommandA, x0: number, y0: number): CommandC[];

View File

@@ -0,0 +1,75 @@
import { SVGPathData } from "./SVGPathData";
export declare type CommandM = {
relative: boolean;
type: typeof SVGPathData.MOVE_TO;
x: number;
y: number;
};
export declare type CommandL = {
relative: boolean;
type: typeof SVGPathData.LINE_TO;
x: number;
y: number;
};
export declare type CommandH = {
relative: boolean;
type: typeof SVGPathData.HORIZ_LINE_TO;
x: number;
};
export declare type CommandV = {
relative: boolean;
type: typeof SVGPathData.VERT_LINE_TO;
y: number;
};
export declare type CommandZ = {
type: typeof SVGPathData.CLOSE_PATH;
};
export declare type CommandQ = {
relative: boolean;
type: typeof SVGPathData.QUAD_TO;
x1: number;
y1: number;
x: number;
y: number;
};
export declare type CommandT = {
relative: boolean;
type: typeof SVGPathData.SMOOTH_QUAD_TO;
x: number;
y: number;
};
export declare type CommandC = {
relative: boolean;
type: typeof SVGPathData.CURVE_TO;
x1: number;
y1: number;
x2: number;
y2: number;
x: number;
y: number;
};
export declare type CommandS = {
relative: boolean;
type: typeof SVGPathData.SMOOTH_CURVE_TO;
x2: number;
y2: number;
x: number;
y: number;
};
export declare type CommandA = {
relative: boolean;
type: typeof SVGPathData.ARC;
rX: number;
rY: number;
xRot: number;
sweepFlag: 0 | 1;
lArcFlag: 0 | 1;
x: number;
y: number;
cX?: number;
cY?: number;
phi1?: number;
phi2?: number;
};
export declare type SVGCommand = CommandM | CommandL | CommandH | CommandV | CommandZ | CommandQ | CommandT | CommandC | CommandS | CommandA;
export declare type TransformFunction = (input: SVGCommand) => SVGCommand | SVGCommand[];