Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void setup(){
- size(400,400);
- fill(255,0,0);
- for( int i = 0; i<400; i+=20){
- line (i,0,i,height); //vertical height
- }
- for (int i =0; i<400; i+=20){
- line(0,i,width,i); //hortizontal lines
- }
- }
- void draw(){
- }
- void mousePressed(){
- rect(mouseX - mouseX%20 , mouseY - mouseY%20, 20, 20);
- //click the mouse and it generates a rectangle at a point on the grid near where you clicked.
- //mouseX has the remainder of mouseX divided by 20 subtracted, so that it lands on a multiple of 20. same for mouse Y
- //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
- //this makes the grid filled with red
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement