Results 1 to 3 of 3

Thread: Grid Painting?

  1. #1
    iCon09 is offline Member
    Join Date
    Feb 2011
    Posts
    9
    Rep Power
    0

    Default Grid Painting?

    This has been resolved, thanks.
    Last edited by iCon09; 02-26-2011 at 08:01 PM.

  2. #2
    mr_guy is offline Member
    Join Date
    Feb 2011
    Posts
    18
    Rep Power
    0

    Default

    something like this should work:
    Java Code:
    int h; // height of grid
    int l = 0;
    int r = 2*h;
    
    for(int i = 0; i < h; i++){
     grid.setColor(i,l,Color.RED);
     l++;
     grid.setColor(i,l,Color.RED);
     l++;
     grid.setColor(i,r,Color.RED);
     r--;
     grid.setColor(i,r,Color.RED);
     r--;
    }
    the int "l" is used to draw a line from the top left to the bottom right and the int "r" is used to draw a line from the top right to the bottom left

  3. #3
    iCon09 is offline Member
    Join Date
    Feb 2011
    Posts
    9
    Rep Power
    0

    Default

    Quote Originally Posted by mr_guy View Post
    something like this should work:
    Java Code:
    int h; // height of grid
    int l = 0;
    int r = 2*h;
    
    for(int i = 0; i < h; i++){
     grid.setColor(i,l,Color.RED);
     l++;
     grid.setColor(i,l,Color.RED);
     l++;
     grid.setColor(i,r,Color.RED);
     r--;
     grid.setColor(i,r,Color.RED);
     r--;
    }
    the int "l" is used to draw a line from the top left to the bottom right and the int "r" is used to draw a line from the top right to the bottom left
    Thanks man, that wasn't quite right but I derived the correct code from your example, I appreciate it.

Similar Threads

  1. painting whole label
    By simprepol in forum AWT / Swing
    Replies: 9
    Last Post: 01-27-2011, 08:10 AM
  2. Painting Problem!
    By Jcbconway in forum Advanced Java
    Replies: 3
    Last Post: 11-17-2010, 04:14 AM
  3. Painting in SWT
    By jionnet in forum SWT / JFace
    Replies: 9
    Last Post: 09-24-2010, 06:52 AM
  4. Painting
    By xael in forum New To Java
    Replies: 6
    Last Post: 09-06-2010, 05:10 AM
  5. Objects painting themselves?
    By martypapa in forum Java 2D
    Replies: 19
    Last Post: 02-06-2010, 04:08 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •