metafizzy / metafizzy/zdog

using for-loop and variables in path command

Open
#110 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
10.7k
Forks
407
PR merge metrics
No merged PRs in 30d

Description

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!

Contributor guide

Open the contributing guide

Research direction

No file, test, or entry point is named in the issue. Start by reading the path API documentation and its implementation, then determine whether paths can be generated with loop variables; done should be a clear supported-usage answer or a scoped change with coverage.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
computer-graphics
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.