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.
104 lines (103 loc) • 4.28 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 _DucElementStylesBase {
constructor() {
this.bb = null;
this.bb_pos = 0;
}
__init(i, bb) {
this.bb_pos = i;
this.bb = bb;
return this;
}
static getRootAs_DucElementStylesBase(bb, obj) {
return (obj || new _DucElementStylesBase()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
static getSizePrefixedRootAs_DucElementStylesBase(bb, obj) {
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
return (obj || new _DucElementStylesBase()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
roundness() {
const offset = this.bb.__offset(this.bb_pos, 4);
return offset ? this.bb.readFloat64(this.bb_pos + offset) : 0.0;
}
blending() {
const offset = this.bb.__offset(this.bb_pos, 6);
return offset ? this.bb.readUint8(this.bb_pos + offset) : null;
}
background(index, obj) {
const offset = this.bb.__offset(this.bb_pos, 8);
return offset ? (obj || new ElementBackground()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null;
}
backgroundLength() {
const offset = this.bb.__offset(this.bb_pos, 8);
return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
}
stroke(index, obj) {
const offset = this.bb.__offset(this.bb_pos, 10);
return offset ? (obj || new ElementStroke()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null;
}
strokeLength() {
const offset = this.bb.__offset(this.bb_pos, 10);
return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
}
opacity() {
const offset = this.bb.__offset(this.bb_pos, 12);
return offset ? this.bb.readFloat64(this.bb_pos + offset) : 0.0;
}
static start_DucElementStylesBase(builder) {
builder.startObject(5);
}
static addRoundness(builder, roundness) {
builder.addFieldFloat64(0, roundness, 0.0);
}
static addBlending(builder, blending) {
builder.addFieldInt8(1, blending, null);
}
static addBackground(builder, backgroundOffset) {
builder.addFieldOffset(2, backgroundOffset, 0);
}
static createBackgroundVector(builder, data) {
builder.startVector(4, data.length, 4);
for (let i = data.length - 1; i >= 0; i--) {
builder.addOffset(data[i]);
}
return builder.endVector();
}
static startBackgroundVector(builder, numElems) {
builder.startVector(4, numElems, 4);
}
static addStroke(builder, strokeOffset) {
builder.addFieldOffset(3, strokeOffset, 0);
}
static createStrokeVector(builder, data) {
builder.startVector(4, data.length, 4);
for (let i = data.length - 1; i >= 0; i--) {
builder.addOffset(data[i]);
}
return builder.endVector();
}
static startStrokeVector(builder, numElems) {
builder.startVector(4, numElems, 4);
}
static addOpacity(builder, opacity) {
builder.addFieldFloat64(4, opacity, 0.0);
}
static end_DucElementStylesBase(builder) {
const offset = builder.endObject();
return offset;
}
static create_DucElementStylesBase(builder, roundness, blending, backgroundOffset, strokeOffset, opacity) {
_DucElementStylesBase.start_DucElementStylesBase(builder);
_DucElementStylesBase.addRoundness(builder, roundness);
if (blending !== null)
_DucElementStylesBase.addBlending(builder, blending);
_DucElementStylesBase.addBackground(builder, backgroundOffset);
_DucElementStylesBase.addStroke(builder, strokeOffset);
_DucElementStylesBase.addOpacity(builder, opacity);
return _DucElementStylesBase.end_DucElementStylesBase(builder);
}
}