Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. void setup(){
  2. size(400,400);
  3. fill(255,0,0);
  4.  
  5. for( int i = 0; i<400; i+=20){
  6. line (i,0,i,height); //vertical height
  7. }
  8.  
  9. for (int i =0; i<400; i+=20){
  10. line(0,i,width,i); //hortizontal lines
  11. }
  12.  
  13.  
  14. }
  15.  
  16. void draw(){
  17. }
  18.  
  19. void mousePressed(){
  20. rect(mouseX - mouseX%20 , mouseY - mouseY%20, 20, 20);
  21. //click the mouse and it generates a rectangle at a point on the grid near where you clicked.
  22. //mouseX has the remainder of mouseX divided by 20 subtracted, so that it lands on a multiple of 20. same for mouse Y
  23. //since the grade is split into multiples of 20, this ensures that a square is drawn on the grid inside of the pre-exisitng lines
  24. //this makes the grid filled with red
  25.  
  26.  
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement