Advertisement
daixso

10x10 Drawing Grid

Jan 23rd, 2017
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.23 KB | None | 0 0
  1. ####
  2. # Author: Zachary Williams
  3. # Written in Java using the Processing framework
  4. # Purpose: The program takes a 600 x 600 canvas and makes it a 10x10 grid.
  5. #          You can provide coordinate pairs in blx (block x) and bly (block y).
  6. #          And the program will rectangles and then fill them in so you can draw shapes or designs.
  7. ####
  8. int step = 0;
  9. int grid = 60;
  10. int [] blx = { 3, 4, 4, 3, 7, 8, 7, 8, 5, 6, 4, 5, 6, 7, 4, 5, 6, 7, 4, 7};
  11. int [] bly = { 3, 3, 4, 4, 3, 3, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8};
  12. int valx;
  13. int valy;
  14.  
  15. void setup()
  16. {
  17.   size(600, 600);
  18.   background(0, 255, 0);
  19. }
  20.  
  21. void draw()
  22. {
  23.   noStroke();
  24.  
  25.   for(int i = 0; i <= 10; i++)
  26.   {
  27.     for(int j = 0; j <= 10; j++)
  28.     {
  29.       for(int val = 0; val < blx.length; val++)
  30.       {
  31.         if(blx[val] == i && bly[val] == j)
  32.         {
  33.           fill(0);
  34.           print(i * grid);
  35.           rect(i * grid, j * grid, grid, grid);
  36.         }
  37.       }
  38.       line(i * grid, j * grid, i * grid, 0);
  39.       line(0, j * grid, i * grid, j * grid);
  40.     }
  41.     noLoop();
  42.   }
  43.  
  44.   //for(int i = 0; i <= width; i += grid)
  45.   //{
  46.   //  line(i, height, i, 0);
  47.   //}
  48.   //for(int j = 0; j <= height; j += grid)
  49.   //{
  50.   //  line(0, j, width, j);
  51.   //}
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement