Advertisement
Guest User

Untitled

a guest
Feb 24th, 2020
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. /* Using Perlin noise. Example adapted from http://courses.haigarmen.com/desn315/files/2013/10/GenerativeArt-2.pdf
  2. See the Processing reference for the noise() function
  3. */
  4.  
  5. int step = 10;
  6. float lastx = -999;
  7. float lasty = -999;
  8. float ynoise = random(10);
  9. float y;
  10.  
  11. void setup(){
  12. size(500, 100);
  13. background(255);
  14. strokeWeight(5);
  15. smooth();
  16. stroke(0, 30);
  17. }
  18. void draw(){
  19. stroke(20, 50, 70,1);
  20.  
  21. for (int x=20; x<=480; x+=step) {
  22. y = 10 + noise(ynoise) * 80;
  23. if (lastx > -999) {
  24. line(x, y, lastx, lasty);
  25. }
  26. lastx = x;
  27. lasty = y;
  28. ynoise += 0.1;
  29. }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement