'p5.js: Let the computer draw something

I would like to let the computer draw something. It should look like a human is drawing something on a paper, with random values.

This is my try:

function setup() {
  createCanvas(500, 500);
  frameRate(30);
}

function draw() {
  x1 = random(500);
  y1 = random(500);
  x2 = random(500);
  y2 = random(500);
  line(x1, y1, x2, y2);
}
<script src="https://cdn.jsdelivr.net/npm/[email protected]/lib/p5.js"></script>

So at the moment, it just puts random lines on top of each other. But it should result in one long connected scribble with curves, like this:

How is it possible to code it like that?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source