java, rectangle size issues.
I am using this code to try and draw a sequence of rectangles from the top left tot he lower right, but each rectangle is twice the size of the last, I have tried rethinking th emath and several other formulas and am ready to just assume I can't do math and give up. can anyone point out where my math is flawed? I want all the rectangles to be the same size, and 10 pixels x, and 10 pixels y away from eachother. values of bottom and right are scrollbars telling how far to offset the rectangles. (I appologize if I typed triangle anywhere above, I am thinking rectangle but typing trable all the time. :-P
private void drawS(Graphics g) { System.out.println("drawS"); int ammount = Ammount; // I am testing this with Ammount = 5 int X = (0 - Bottom); int Y = (0 - Right); int X2 = (X + Size); int Y2 = (Y + Size); while (ammount > 0) { g.drawRect(X,Y,X2,Y2); ammount--; X = (X2 + 10); Y = (Y2 + 10); X2 = (X + Size); Y2 = (Y + Size); } } |
nevermind, I just misunderstood the drawRect function, I got it :-P
|
All times are GMT -5. The time now is 10:07 PM. |