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));
}

    • Related Articles

    • Scripting Example: Rose

      This is an advanced feature: see Scripting Explained. To make this print: Use this script: const rose = (centerX, centerY, stepCount, turns, n, d, A) => {   var results = [];    var k = n / d;   var stepSize = turns * 2 * Math.PI / (stepCount);   for ...
    • Scripting Example: Triskelion x5

      This is an advanced feature: see Scripting Explained. To make this print: Use this script: var CENTER_X = 126, CENTER_Y = 84; function reverse(arr) {   var res = [];   for (var i = 0; i < arr.length; i += 2) {     res[i] = arr[arr.length - i -2];     ...
    • Scripting Explained

      You can write JavaScript statements to tell Foodini what to print, giving you precise control. Many schools like this feature for a fun way to teach kids how to code. Don't know JavaScript? Don't worry! This is an advanced feature for those that want ...
    • Scripting Example: Mini swirl flowers x6

      This is an advanced feature: see Scripting Explained. To make this print: Use this script: const rose = (centerX, centerY, stepCount, turns, n, d, A) => {   var results = [];    var k = n / d;   var stepSize = turns * 2 * Math.PI / (stepCount);   for ...
    • Shapes/Creations: What are they, and How-To Create

      A successful Foodini print is made up of 2 main elements: shapes (creations) and ingredients (fillings). Shapes/creations are the shapes that print. Ingredients/fillings are the ingredients that are loaded into the capsules and printed - into ...