ducjs
Version:
The duc 2D CAD file format is a cornerstone of our advanced design system, conceived to cater to professionals seeking precision and efficiency in their design work.
70 lines (69 loc) • 2.82 kB
JavaScript
// automatically generated by the FlatBuffers compiler, do not modify
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
import * as flatbuffers from 'flatbuffers';
import { ElementBackground } from '../duc/element-background';
import { ElementStroke } from '../duc/element-stroke';
export class DucPath {
constructor() {
this.bb = null;
this.bb_pos = 0;
}
__init(i, bb) {
this.bb_pos = i;
this.bb = bb;
return this;
}
static getRootAsDucPath(bb, obj) {
return (obj || new DucPath()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
static getSizePrefixedRootAsDucPath(bb, obj) {
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
return (obj || new DucPath()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
lineIndices(index) {
const offset = this.bb.__offset(this.bb_pos, 4);
return offset ? this.bb.readInt32(this.bb.__vector(this.bb_pos + offset) + index * 4) : 0;
}
lineIndicesLength() {
const offset = this.bb.__offset(this.bb_pos, 4);
return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
}
lineIndicesArray() {
const offset = this.bb.__offset(this.bb_pos, 4);
return offset ? new Int32Array(this.bb.bytes().buffer, this.bb.bytes().byteOffset + this.bb.__vector(this.bb_pos + offset), this.bb.__vector_len(this.bb_pos + offset)) : null;
}
background(obj) {
const offset = this.bb.__offset(this.bb_pos, 6);
return offset ? (obj || new ElementBackground()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null;
}
stroke(obj) {
const offset = this.bb.__offset(this.bb_pos, 8);
return offset ? (obj || new ElementStroke()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null;
}
static startDucPath(builder) {
builder.startObject(3);
}
static addLineIndices(builder, lineIndicesOffset) {
builder.addFieldOffset(0, lineIndicesOffset, 0);
}
static createLineIndicesVector(builder, data) {
builder.startVector(4, data.length, 4);
for (let i = data.length - 1; i >= 0; i--) {
builder.addInt32(data[i]);
}
return builder.endVector();
}
static startLineIndicesVector(builder, numElems) {
builder.startVector(4, numElems, 4);
}
static addBackground(builder, backgroundOffset) {
builder.addFieldOffset(1, backgroundOffset, 0);
}
static addStroke(builder, strokeOffset) {
builder.addFieldOffset(2, strokeOffset, 0);
}
static endDucPath(builder) {
const offset = builder.endObject();
return offset;
}
}