UNPKG

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.

155 lines (154 loc) 6.27 kB
// 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 { DucFreeDrawEnds } from '../duc/duc-free-draw-ends'; import { DucPoint } from '../duc/duc-point'; import { _DucElementBase } from '../duc/duc-element-base'; export class DucFreeDrawElement { constructor() { this.bb = null; this.bb_pos = 0; } __init(i, bb) { this.bb_pos = i; this.bb = bb; return this; } static getRootAsDucFreeDrawElement(bb, obj) { return (obj || new DucFreeDrawElement()).__init(bb.readInt32(bb.position()) + bb.position(), bb); } static getSizePrefixedRootAsDucFreeDrawElement(bb, obj) { bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); return (obj || new DucFreeDrawElement()).__init(bb.readInt32(bb.position()) + bb.position(), bb); } base(obj) { const offset = this.bb.__offset(this.bb_pos, 4); return offset ? (obj || new _DucElementBase()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null; } points(index, obj) { const offset = this.bb.__offset(this.bb_pos, 6); return offset ? (obj || new DucPoint()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null; } pointsLength() { const offset = this.bb.__offset(this.bb_pos, 6); return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; } size() { const offset = this.bb.__offset(this.bb_pos, 8); return offset ? this.bb.readFloat64(this.bb_pos + offset) : 0.0; } thinning() { const offset = this.bb.__offset(this.bb_pos, 10); return offset ? this.bb.readFloat32(this.bb_pos + offset) : 0.0; } smoothing() { const offset = this.bb.__offset(this.bb_pos, 12); return offset ? this.bb.readFloat32(this.bb_pos + offset) : 0.0; } streamline() { const offset = this.bb.__offset(this.bb_pos, 14); return offset ? this.bb.readFloat32(this.bb_pos + offset) : 0.0; } easing(optionalEncoding) { const offset = this.bb.__offset(this.bb_pos, 16); return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; } start(obj) { const offset = this.bb.__offset(this.bb_pos, 18); return offset ? (obj || new DucFreeDrawEnds()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null; } end(obj) { const offset = this.bb.__offset(this.bb_pos, 20); return offset ? (obj || new DucFreeDrawEnds()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null; } pressures(index) { const offset = this.bb.__offset(this.bb_pos, 22); return offset ? this.bb.readFloat32(this.bb.__vector(this.bb_pos + offset) + index * 4) : 0; } pressuresLength() { const offset = this.bb.__offset(this.bb_pos, 22); return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; } pressuresArray() { const offset = this.bb.__offset(this.bb_pos, 22); return offset ? new Float32Array(this.bb.bytes().buffer, this.bb.bytes().byteOffset + this.bb.__vector(this.bb_pos + offset), this.bb.__vector_len(this.bb_pos + offset)) : null; } simulatePressure() { const offset = this.bb.__offset(this.bb_pos, 24); return offset ? !!this.bb.readInt8(this.bb_pos + offset) : false; } lastCommittedPoint(obj) { const offset = this.bb.__offset(this.bb_pos, 26); return offset ? (obj || new DucPoint()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null; } svgPath(optionalEncoding) { const offset = this.bb.__offset(this.bb_pos, 28); return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; } static startDucFreeDrawElement(builder) { builder.startObject(13); } static addBase(builder, baseOffset) { builder.addFieldOffset(0, baseOffset, 0); } static addPoints(builder, pointsOffset) { builder.addFieldOffset(1, pointsOffset, 0); } static createPointsVector(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 startPointsVector(builder, numElems) { builder.startVector(4, numElems, 4); } static addSize(builder, size) { builder.addFieldFloat64(2, size, 0.0); } static addThinning(builder, thinning) { builder.addFieldFloat32(3, thinning, 0.0); } static addSmoothing(builder, smoothing) { builder.addFieldFloat32(4, smoothing, 0.0); } static addStreamline(builder, streamline) { builder.addFieldFloat32(5, streamline, 0.0); } static addEasing(builder, easingOffset) { builder.addFieldOffset(6, easingOffset, 0); } static addStart(builder, startOffset) { builder.addFieldOffset(7, startOffset, 0); } static addEnd(builder, endOffset) { builder.addFieldOffset(8, endOffset, 0); } static addPressures(builder, pressuresOffset) { builder.addFieldOffset(9, pressuresOffset, 0); } static createPressuresVector(builder, data) { builder.startVector(4, data.length, 4); for (let i = data.length - 1; i >= 0; i--) { builder.addFloat32(data[i]); } return builder.endVector(); } static startPressuresVector(builder, numElems) { builder.startVector(4, numElems, 4); } static addSimulatePressure(builder, simulatePressure) { builder.addFieldInt8(10, +simulatePressure, +false); } static addLastCommittedPoint(builder, lastCommittedPointOffset) { builder.addFieldOffset(11, lastCommittedPointOffset, 0); } static addSvgPath(builder, svgPathOffset) { builder.addFieldOffset(12, svgPathOffset, 0); } static endDucFreeDrawElement(builder) { const offset = builder.endObject(); return offset; } }