LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-13-2004, 04:42 PM   #1
exodist
Senior Member
 
Registered: Aug 2003
Location: Portland, Oregon
Distribution: Arch
Posts: 1,374

Rep: Reputation: 47
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);
}
}
 
Old 03-13-2004, 04:48 PM   #2
exodist
Senior Member
 
Registered: Aug 2003
Location: Portland, Oregon
Distribution: Arch
Posts: 1,374

Original Poster
Rep: Reputation: 47
nevermind, I just misunderstood the drawRect function, I got it :-P
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Xlib Code --- Why not Drawing Rectangle?????? pihu Programming 1 07-18-2005 01:05 PM
Font size issues in Gentoo with Fluxbox PGDubbin Linux - General 6 01-13-2005 05:47 PM
Recommend me a sprite rectangle clearing algorithm MadCactus Programming 2 10-09-2004 01:11 PM
Controlling size of JLabel and JTextFields in Java linux_ub Programming 0 07-27-2004 08:32 AM
strange java font size on X leomekenkamp Linux - Software 1 07-07-2003 03:39 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:23 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration