using for-loop and variables in path command
allonestring opened this issue · comments
In other languages, if I wanted to draw a star, say, I'd have something like this:
startShape();
for (i = 0; i < numPoints; i++)
{
angleR = TAU/numPoints * i;
angler = TAU/numPoints * (i + 0.5);
vertex(bigRadius * cos(angleR), bigRadius * sin(angleR));
vertex(smallRadius * cos(angler), smallRadius * sin(angler));
}
endShape();
Can I do something similar in zdog? If so, I can't work out how, nor can I work out how to pass a variable to the path command.
var x1 = Math.random(-50, 50);
var y1 = Math.random(-50, 50);
var z1 = Math.random(-50, 50);
var x2 = Math.random(-50, 50);
var y2 = Math.random(-50, 50);
var z2 = Math.random(-50, 50);
new Zdog.Shape({
...
path: [
{ x: x1, y: y1, z: z1 },
{ x: x2, y: y2, z: z2 },
],
...
Have I got the syntax wrong or am I hoping for too much?
Thanks!
I think you can have random paths, I've seen it in this demo.. study it to see how it's done..