How to use the makerjs.environmentTypes 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 / demos / js / nameplate.js View on Github external
function Nameplate(fontPath, text, fontSize, fontMargin, boltMargin, boltRadius, rounded) {

    var _this = this;

    if (makerjs.environment == makerjs.environmentTypes.NodeJs) {

        (function () {
            var opentype = require('opentype.js');
            var font = opentype.loadSync('./fonts/' + fontPath);

            //use the models from makerjs-nameplate
            _this.models = new _nameplate(font, text, fontSize, fontMargin, boltMargin, boltRadius, rounded).models;
        })();

    } else {

        //load a font asynchronously
        opentype.load('/fonts/' + fontPath, function (err, font) {
            if (!err) {

                //use the models from makerjs-nameplate

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

67 / 100
Full package analysis