I want to draw curve from X points, random points.

I try to read about the bezierPoint() but not understood completely

I want to draw curve from X points, random points.

I try to read about the bezierPoint() but not understood completely

Hi @yalaniv,

If you want to draw a random curve, `bezierPoint()`

is not the right function to use because it lets you do this :

Evaluates the Bezier at point t for points a, b, c, d. The parameter t varies between 0 and 1, a and d are points on the curve, and b and c are the control points.

Which allow you to get a point on a bezier curve at a certain position on that curve (from 0 to 1). Usually you use it with the `bezier()`

function to display it.

The easiest way is to use `curveVertex()`

to display a curve, you just give points and it construct a curve for you.

Then for randomness you need :

1 Like

Here is a solution with bezierCurve.

```
int prevX;
int prevY;
void setup() {
size(400, 400);
strokeWeight(2);
noFill();
}
void draw() {
background(200);
// First point at the left edge
prevX = 0;
prevY = height/2;
// For loop gets repeated till right edge is reached
for(int i = 1; i < 11; i++) {
// Updatet x positino and create a new random Y value
int x = i * 40;
int y = int(random(height));
// Draw a bezier line from the previous to the current point
// Comment: replace "15" to adjust the handles
bezier(prevX, prevY, prevX+15, prevY, x-15, y, x, y);
// Make the current point the previous one.
prevX = x;
prevY = y;
}
// Stop drawing
noLoop();
}
void mouseClicked() {
loop();
}
```

`bezierPoint`

is used to get a point on a `bezierCurve`

.

3 Likes

thanks for the awesome information.

2 Likes

thanks my issue has been fixed.