本文整理汇总了TypeScript中makerjs.exporter类的典型用法代码示例。如果您正苦于以下问题:TypeScript exporter类的具体用法?TypeScript exporter怎么用?TypeScript exporter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了exporter类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: toStl
function toStl(model: MakerJs.IModel, options: MakerJs.exporter.IJscadCsgOptions) {
if (!deps[MakerJsPlaygroundExport.ExportFormat.Stl]) {
importScripts(
'../../../external/jscad/csg.js',
'../../../external/jscad/stl-serializer.js'
);
deps[MakerJsPlaygroundExport.ExportFormat.Stl] = true;
}
//make sure size is in mm for STL
model = makerjs.model.convertUnits(model, makerjs.unitType.Millimeter);
const { CAG }: { CAG: typeof jscad.CAG } = require('@jscad/csg');
const stlSerializer: jscad.StlSerializer = require('@jscad/stl-serializer');
options.statusCallback = function (status) {
result.percentComplete = status.progress;
postMessage(result);
}
return makerjs.exporter.toJscadSTL(CAG, stlSerializer, model, options);
}
示例2: toPdf
function toPdf(model: MakerJs.IModel, exportOptions: MakerJs.exporter.IPDFRenderOptions) {
if (!deps[MakerJsPlaygroundExport.ExportFormat.Pdf]) {
importScripts(
'../../../external/text-encoding/encoding-indexes.js',
'../../../external/text-encoding/encoding.js',
'../../../external/PDFKit/pdfkit.js',
'string-reader.js'
);
deps[MakerJsPlaygroundExport.ExportFormat.Pdf] = true;
}
function complete(pdfDataString: string) {
result.text = pdfDataString;
result.percentComplete = 100;
postMessage(result);
}
//TODO: watermark
//TODO: title, author, grid from options
var pdfOptions: PDFKit.PDFDocumentOptions = {
compress: false,
info: {
Producer: 'MakerJs',
Author: 'MakerJs'
}
};
var doc: PDFKit.PDFDocument = new PDFDocument(pdfOptions);
var reader = new StringReader(complete);
var stream = doc.pipe(reader);
//TODO: break up model across pages
makerjs.exporter.toPDF(doc, model, exportOptions);
doc.end();
}
示例3:
[0 - SCALE, 0 - SCALE]
);
layer.models = {border, holes};
layer.layer = name;
// layerOptions[name] = {fill: `hsla(${360 / PAGES * i}, 100%, 50%, 1)`};
// layerOptions[name] = {fill: i%2===0 ? 'grey' : 'black'};
const x = i % COLS * (BOARD + MARGIN);
const y = Math.floor(i / COLS) * (BOARD + MARGIN);
MakerJs.model.move(layer, [x, -y]);
expanded[name] = layer;
}
const cut = {
models: {
// line: makerPath,
expanded: {models: expanded}
}
};
console.log(cut);
const svg = MakerJs.exporter.toSVG(cut, {
// useSvgPathOnly: !DEBUG,
// annotate: DEBUG,
fill: 'white',
// stroke: 'none',
layerOptions
});
document.write(svg);
document.body.style.backgroundColor = 'hsla(0, 0%, 90%, 1)';
示例4: toDXF
function toDXF(model: MakerJs.IModel, options: MakerJs.exporter.IDXFRenderOptions) {
if (!options.units) {
options.units = model.units || makerjs.unitType.Millimeter;
}
return makerjs.exporter.toDXF(model, options);
}