Example #1
0
            .on('response', res => {
                drawInIterm(res, err => {
                    if (err) {
                        reject(err);
                        return;
                    }

                    resolve();
                });
            });
Example #2
0
  B: toColor(lego.colors.BRIGHT_BLUE),
};

// build cubes
for (var i = 0; i < figure.length; i++) {
  var figureSquare = figure[i].reverse();
  for (var j = 0; j < figureSquare.length; j++) {
    var figureRow = figureSquare[j].reverse();
    for (var k = 0; k < figureRow.length; k++) {
      var p3d = new obelisk.Point3D(20 * j, 20 * k, (32 + 1) * i);
      var cubeDms = new obelisk.CubeDimension(20, 20, 32);
      var figureCell = figureRow[k];
      if (colors[figureCell]) {
        var cubeColor = colors[figureCell];
      } else {
        var cubeColor = new obelisk.CubeColor().getByHorizontalColor(0xF2F3F2);
      }
      if (figureCell !== ' ') {
        var cube = new obelisk.Cube(cubeDms, cubeColor, false);
        pixelView.renderObject(cube, p3d);
      }
    }
  }
}

if (process.env.TERM_PROGRAM === 'iTerm.app') {
  itermDraw(canvas.createPNGStream());
} else {
  canvas.createPNGStream().pipe(fs.createWriteStream('./figure.png'));
}