How to use the makerjs.unitType function in makerjs

To help you get started, weā€™ve selected a few makerjs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github microsoft / maker.js / packages / playground / src / worker / export-worker.ts View on Github external
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);
            }
            return toDXF;
github microsoft / maker.js / demos / js / makerjs-ventgridcircle.js View on Github external
function VentgridCircle(filterRadius, spacing, radius) {
        this.filterRadius = filterRadius;
        this.spacing = spacing;
        this.radius = radius;
        this.id = 'ventgridcircleInstance';
        this.units = makerjs.unitType.Millimeter;
        this.paths = {};
        this.rim = new makerjs.paths.Circle([0, 0], radius);
        var ventgridInstance = new ventgrid(filterRadius, spacing, radius, radius);
        for (var id in ventgridInstance.paths) {
            var circle = ventgridInstance.paths[id];
            this.checkCircle(id, circle);
        }
    }
    VentgridCircle.prototype.checkCircle = function (id, circle) {
github microsoft / maker.js / demos / card.js View on Github external
var text = makerjs.model.scale(new makerjs_monotext('MAKERJS.ORG'), textScale);
	var textW = hCenter(text, textY);

	var tabW = textW + tabMargin;
	var tab = new makerjs.models.RoundRectangle(tabW, tabHeight, tabR);
	hCenter(tab, rim - tabR);

	var innerW = w - 2 * rim;
	var innerH = h - 2 * rim;

	var inner = new makerjs.models.RoundRectangle(innerW, innerH, rim);
	inner.origin = [rim, rim];
	flipArcs(inner);

	this.units = makerjs.unitType.Millimeter;
	this.paths = {};
	
	var plus = {
		origin: [w / 2, h / 2],
		models: {
			v: makerjs.model.move(new makerjs.models.Rectangle(conn, h * 2), [conn / -2, -h]),
			h: makerjs.model.move(new makerjs.models.Rectangle(w * 2, conn), [-w, conn / -2])
		}
	}
	
	makerjs.model.rotate(plus, -logoAngle, plus.origin);

	this.models = {
		text: text, 
		outer: outer, 
		bolts: bolts,
github microsoft / maker.js / docs / playground / js / worker / export-worker.js View on Github external
function toStl(model, options) {
                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);
                var CAG = require('@jscad/csg').CAG;
                var stlSerializer = require('@jscad/stl-serializer');
                options.statusCallback = function (status) {
                    result.percentComplete = status.progress;
                    postMessage(result);
                };
                return makerjs.exporter.toJscadSTL(CAG, stlSerializer, model, options);
            }
            return toStl;
github microsoft / maker.js / demos / js / makerjs-nameplate.js View on Github external
//make a rectangle around the bolts
    var Rect = rounded ? makerjs.models.RoundRectangle : makerjs.models.Rectangle;
    var rect = new Rect(bolts, boltMargin);

    //save all of these in the model
    this.models = {
        text: textModel,
        rect: rect,
        bolts: bolts
    };

    //move everything to [0, 0]
    makerjs.model.zero(this);

    this.units = makerjs.unitType.Millimeter;
}

makerjs

Maker.js, a Microsoft Garage project, is a JavaScript library for creating and sharing modular line drawings for CNC and laser cutters.

Apache-2.0
Latest version published 1 year ago

Package Health Score

70 / 100
Full package analysis