How to use the makerjs.layout 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 / honeycomb.js View on Github external
function Honeycomb(hexWidth, margin, xcount, ycount) {

  var hex = new m.models.Polygon(6, hexWidth / 2, 30, true);

  this.models = {
    honeycomb: m.layout.cloneToHoneycomb(hex, xcount, ycount, margin)
  };

}
github microsoft / maker.js / demos / js / window-arch-grid.js View on Github external
function WindowArchGrid(width, height, rows, columns, extra, split, spacing, fillet, outerFrame, outerFrameWidth) {
    var column = (width - (columns - 1) * spacing) / columns;
    var row = (height - (rows) * spacing + spacing / 2) / rows;
    var cell = new makerjs.models.RoundRectangle(column, row, fillet);
    var grid = makerjs.layout.cloneToGrid(cell, columns, rows, spacing);

    makerjs.model.center(grid, true, false);
    grid.origin[1] = -height;

    this.models = {
        arch: new WindowArch(width, columns, extra, split, spacing, fillet),
        grid: grid
    };

    if (outerFrame) {
        var frame = new makerjs.models.Dome(width + 2 * outerFrameWidth, height + width / 2 + 2 * outerFrameWidth);
        frame.origin = [0, -height - outerFrameWidth];
        this.models.frame = frame;
    }
}
github microsoft / maker.js / docs / demos / js / tongue-and-groove.js View on Github external
function TongueAndGroove(count, tongueWidth, grooveWidth, grooveDepth, radius, style) {

  //Tongue and grooves for a box joint
  var groove = new m.models.Dogbone(grooveWidth, grooveDepth, radius, style, true);

  groove.paths.leftTongue = new m.paths.Line([-tongueWidth / 2, 0], [0, 0]);
  groove.paths.rightTongue = new m.paths.Line([grooveWidth, 0], [grooveWidth + tongueWidth / 2, 0]);

  this.models = {
    tng: m.layout.cloneToRow(groove, count)
  };

  this.origin = [tongueWidth / 2, 0];
}
github microsoft / maker.js / demos / js / fish-scales.js View on Github external
function FishScales(radius, sweep, xcount, ycount, expand, expansion) {

  var s2 = sweep / 2;
  var arc = new m.paths.Arc([0, 0], radius, 90 - s2, 90 + s2);

  this.models = {
    scales: m.layout.cloneToBrick(arc, xcount, ycount)
  };

  if (expand) {
    this.models.scales = m.model.expandPaths(this, expansion);
  }

}
github microsoft / maker.js / demos / js / tongue-and-groove.js View on Github external
function TongueAndGroove(count, tongueWidth, grooveWidth, grooveDepth, dogbone) {

  //Tongue and grooves for a box joint
  var groove = new m.models.Dogbone(grooveWidth, grooveDepth, dogbone, 0, true);

  groove.paths.leftTongue = new m.paths.Line([-tongueWidth / 2, 0], [0, 0]);
  groove.paths.rightTongue = new m.paths.Line([grooveWidth, 0], [grooveWidth + tongueWidth / 2, 0]);

  this.models = {
    tng: m.layout.cloneToRow(groove, count)
  };

  this.origin = [tongueWidth / 2, 0];
}
github microsoft / maker.js / docs / demos / js / text-on-path.js View on Github external
function TextOnPath(font, fontSize, topText, topSpan, bottomText, bottomSpan, baseline, contain, rotate, showPath) {

    var topTextModel = new makerjs.models.Text(font, topText, fontSize);
    var bottomTextModel = new makerjs.models.Text(font, bottomText, fontSize);

    var topArc = new makerjs.paths.Arc([0, 0], 100, 90 - topSpan / 2, 90 + topSpan / 2);
    var bottomArc = new makerjs.paths.Arc([0, 0], 100, 270 - bottomSpan / 2, 270 + bottomSpan / 2);

    makerjs.layout.childrenOnPath(topTextModel, topArc, baseline, true, contain, rotate);
    makerjs.layout.childrenOnPath(bottomTextModel, bottomArc, baseline, false, contain, rotate);

    this.models = {
        topText: topTextModel,
        bottomText: bottomTextModel
    };

    if (showPath) {
        this.paths = {
            topArc: topArc,
            bottomArc: bottomArc
        };
    }
}
github microsoft / maker.js / packages / maker.js / examples / textOnChain.js View on Github external
function TextOnChain(font, text, fontSize, baseline, reversed, contain, rotate, svgPathData, showPath) {

    var textModel = new makerjs.models.Text(font, text, fontSize);

    var svgPath = makerjs.importer.fromSVGPathData(svgPathData);
    
    var chain = makerjs.model.findSingleChain(svgPath);

    makerjs.layout.childrenOnChain(textModel, chain, baseline, reversed, contain, rotate);

    this.models = {
        text: textModel
    };

    if (showPath) {
        this.models.svgPath = svgPath;
    }
}
github microsoft / maker.js / docs / demos / js / text-on-path.js View on Github external
function TextOnPath(font, fontSize, topText, topSpan, bottomText, bottomSpan, baseline, contain, rotate, showPath) {

    var topTextModel = new makerjs.models.Text(font, topText, fontSize);
    var bottomTextModel = new makerjs.models.Text(font, bottomText, fontSize);

    var topArc = new makerjs.paths.Arc([0, 0], 100, 90 - topSpan / 2, 90 + topSpan / 2);
    var bottomArc = new makerjs.paths.Arc([0, 0], 100, 270 - bottomSpan / 2, 270 + bottomSpan / 2);

    makerjs.layout.childrenOnPath(topTextModel, topArc, baseline, true, contain, rotate);
    makerjs.layout.childrenOnPath(bottomTextModel, bottomArc, baseline, false, contain, rotate);

    this.models = {
        topText: topTextModel,
        bottomText: bottomTextModel
    };

    if (showPath) {
        this.paths = {
            topArc: topArc,
            bottomArc: bottomArc
        };
    }
}

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 6 months ago

Package Health Score

74 / 100
Full package analysis