Legebatterie

p5js--coloresSquares

Mar 26th, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. //change framerate and thereby the speed of the squares to appear
  2. speed=30;
  3. alph=1;
  4.  
  5.  
  6. function setup() {
  7. createCanvas(600,500);
  8. background(0);
  9. frameRate(speed);
  10. }
  11.  
  12. function draw() {
  13. x=random(1,width);
  14. y=random(1,height);
  15.  
  16. r=map(x,0,width,0,255);
  17. b=map(x,0,width,255,0);
  18. //g=map(y,0,height,255,0);
  19. g=0;
  20. noStroke();
  21. fill(r,g,b,alph);
  22. rect(x,y,40,40);
  23. alph+=1/10;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment