How to generate this kind of random curves?

后端 未结 3 1860
被撕碎了的回忆
被撕碎了的回忆 2021-02-03 14:32

Is it possible to generate this kind of random curves?

\"enter

I\'ve tried IMagick

3条回答
  •  佛祖请我去吃肉
    2021-02-03 15:27

    Looks like:

    x = 0; y = 0; angel = 0;
    while (true) {
       angel = angel + 0.5 - random(1);
       x1 = x + 0.1 * cos(angel);
       y1 = y + 0.1 * sin(angel);
       if (abs(x1 - x) + abs(y1 - y) < 10)
         drawline(x,y,x1,y1);
       x = x1; y = y1;
    
       if (x < 0) x = width;
       if (y < 0) y = height;
       if (x > width) x = 0;
       if (y > height) y = 0;
    }
    

    enter image description here

提交回复
热议问题