Scripting Example: Rose

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 (var theta = 0; theta < d * turns * 2 * Math.PI; theta += stepSize) {
    var x = centerX + A * Math.cos(k * theta) * Math.cos(theta);
    var y = centerY + A * Math.cos(k * theta) * Math.sin(theta); 
    results.push(x, y);
    console.log(x);console.log(y);
  }
  return results;
};

foodini.useIngredient(ingredients[0]);
var X = 256/2, Y = 148/2, SIZE = 60, STEPS = 400, TURNS = 1;
[[5,4]].forEach((nd, i) => {
  const pts = rose(X + 2 * (SIZE + 5)* i, Y, STEPS, TURNS, nd[0], nd[1], SIZE);
  foodini.drawPolyline(pts,false,false);
});