Advertisement
fosterbl

Lightning in Processing

Dec 12th, 2019
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.41 KB | None | 0 0
  1. int startX, startY, endX, endY;
  2.  
  3. void setup(){
  4.   size(640,480);
  5.   startX = 0;
  6.   startY = 150;
  7. }
  8.  
  9. void draw(){
  10.   stroke((int)(Math.random()*256),(int)(Math.random()*256),(int)(Math.random()*256));
  11.   endX = startX + (int)(Math.random() * 9 + 1);
  12.   endY = startY + (int)(Math.random() * 19 - 9);
  13.   line(startX, startY, endX, endY);
  14.   startX = endX;
  15.   startY = endY;
  16.   startX %= width;
  17.   startY %= height;
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement