lbrn2-to-svg
Version:
A library and CLI to parse LightBurn LBRN2 files and convert them to SVG.
93 lines (92 loc) • 2.08 kB
TypeScript
export interface Lbrn2Vec2 {
x: number;
y: number;
c0x?: number;
c0y?: number;
c1x?: number;
c1y?: number;
}
export interface Lbrn2XForm {
a: number;
b: number;
c: number;
d: number;
e: number;
f: number;
}
export interface Lbrn2CutSetting {
index: number;
name: string;
color?: string;
strokeWidth?: string;
}
export interface Lbrn2ShapeBase {
Type: string;
CutIndex: number;
XFormVal: string;
XForm?: Lbrn2XForm;
VertID?: number;
PrimID?: number;
}
export interface Lbrn2Rect extends Lbrn2ShapeBase {
Type: "Rect";
W: number;
H: number;
Cr: number;
}
export interface Lbrn2Ellipse extends Lbrn2ShapeBase {
Type: "Ellipse";
Rx: number;
Ry: number;
}
export interface Lbrn2Path extends Lbrn2ShapeBase {
Type: "Path";
VertList: string;
PrimList: string;
parsedVerts?: Lbrn2Vec2[];
/**
* Array of parsed primitives from PrimList.
* Each primitive is a structured object describing the type and indices.
*/
parsedPrimitives?: PathPrimitiveIR[];
}
export interface Lbrn2Group extends Lbrn2ShapeBase {
Type: "Group";
Children: Lbrn2Shape[];
}
interface Lbrn2Bitmap extends Lbrn2ShapeBase {
Type: "Bitmap";
W: number;
H: number;
Data: string;
File?: string;
Gamma?: number;
Contrast?: number;
Brightness?: number;
EnhanceAmount?: number;
EnhanceRadius?: number;
EnhanceDenoise?: number;
SourceHash?: number;
}
export type Lbrn2Shape = Lbrn2Rect | Lbrn2Ellipse | Lbrn2Path | Lbrn2Group | Lbrn2Bitmap;
export interface LightBurnProjectFile {
LightBurnProject: {
AppVersion: string;
FormatVersion: string;
CutSetting?: Lbrn2CutSetting[] | Lbrn2CutSetting;
Shape?: Lbrn2Shape[] | Lbrn2Shape;
};
}
/**
* Intermediate Representation for parsed path primitives.
*/
export type PathPrimitiveIR = {
type: "Line";
startIdx: number;
endIdx: number;
} | {
type: "Bezier";
startIdx: number;
endIdx: number;
};
export {};