Scripting Example: Hexegon x6

Scripting Example: Hexegon x6

This is an advanced feature: see Scripting Explained.

To make this print:


Use this script:

const polygon = (x, y, size, ang, n) => {
  var result = [];
  var delta = 2 * Math.PI / n;
  ang = ang * 2 * Math.PI / 360;
  for (var i = 0; i <= n; i++) {
    result.push(x + size * Math.cos(ang + i * delta), y + size * Math.sin(ang + i*delta));
  }
  return result;
}
foodini.setParameter("autoZ", 0);
foodini.useIngredient(ingredients[0]);
foodini.setZ(1.2, true);
var CENTER_X = 128, CENTER_Y = 84, SIZE = 40, NUMPOLY = 6, SIDES = 6;
for (var i = 0; i < NUMPOLY; i++) {
  foodini.drawPolyline(polygon(CENTER_X, CENTER_Y, SIZE - 4*i, 15*i, SIDES));
}