```
function segments (points) {
beginShape();
for(let point of points)
vertex(...point);
endShape();
}
function drawCurve(f,a,b,n=200){
segments([...Array(n+1).keys()].map(k => f(a +(b-a)*k/n)));
}
function draw() {
k %= 1;
background(240);
translate(width / 2, height / 2);
scale(scaleFactor, -scaleFactor)
stroke(200);
line(-mx,0,mx,0);
line(0,-mx,0,mx);
drawCurve(t=>[3*sin(2*t),2*cos(3*t)], 0, 2*k*PI);
stroke(0);
drawCurve(t=>[3*sin(2*t),2*cos(3*t)], max(0,2*k*PI-0.5), 2*k*PI);
k += 0.01;
```

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (`</>`

) to add backticks around text.

See this post to find the backtick on your keyboard.

**Note:** Backticks (`) are not single quotes (’).

I’m not sure what you are asking. And your code is incomplete. But maybe take a step back and abstract the problem. Can you provide a sample array and explain what you want to extract from it?

I got the code from a tutorial. It draws a curve. I want to draw additional lines, that intersect the curve at the point currently drawn on the curve. For this I think I need the coordinates of that point. But I have no idea, how to get hold of them.

The Array “Points” contains them. But there seems to be nothing like Points[n].x or whatever gives me the x-coordinate of that point.

And what does *points* look like? Can you log that out and show us what is in it?

Or can you provide a link to a repo?

Hello and thanks for the quick answer.

the full program is this:

```
let scaleFactor = 1;
const mx = 5;
const r = 2;
let k = 0;
function setup()
{
createCanvas(500,500);
scaleFactor = width / mx /2;
strokeWeight(1 / scaleFactor);
noFill();
frameRate(20);
}
// points list eine Liste (Array) von Punkten
function segments (points)
{
beginShape();
for(let point of points)
vertex(...point);
endShape();
}
function drawCurve(f,a,b,n=200)
{
segments([...Array(n+1).keys()].map(k => f(a +(b-a)*k/n)));
}
function draw()
{
k %= 1;
background(240);
translate(width / 2, height / 2);
scale(scaleFactor, -scaleFactor)
stroke(200);
line(-mx,0,mx,0);
line(0,-mx,0,mx);
stroke(0);
//drawCurve(t=>[3*sin(2*t),2*cos(3*t)], 0, 2*k*PI);
```

The task is to draw a vertical and a horizontal line that go with points [3*sin(2*t),2*cos(3*t)] as the curve is drawn.

Best regards

Carsten

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (`</>`

) to add backticks around text.

See this post to find the backtick on your keyboard.

**Note:** Backticks (`) are not single quotes (’).

That cannot be the complete code. You have undefined functions and the last function is incomplete.

If you have working code, please put it in a github repo and provide the link. Then we can test the exact code with your setup.