# Java Graphics Programming Help

Discussion in 'Mac Programming' started by rolex54, Oct 9, 2008.

Joined:
Aug 20, 2007
Location:
Houston, TX
#1
2. ### robbieduncan Moderator emeritus

Joined:
Jul 24, 2002
Location:
London
#2
You are seriously asking us to do your assignment for you? What do you expect to learn from us doing it?

You will be better off handing in what you have and learning from the constructive feedback you get...

3. ### toddburch macrumors 6502a

Joined:
Dec 4, 2006
Location:
Katy, Texas
#3
Is there a specific question in there somewhere?

Todd

4. ### lee1210 macrumors 68040

Joined:
Jan 10, 2005
Location:
Dallas, TX
#4
You're closer, you go smack him.

to the OP:
have you written anything? do you need help w/ methods to draw lines?

-Lee

5. ### rolex54 thread starter macrumors 6502

Joined:
Aug 20, 2007
Location:
Houston, TX
#5
well what i need to do is draw that one in at least the 80 point version
The teacher gave us this formula to use
Start + n(total distance traveled/# of repetitions)
but every time i plug it in I am not getting anything like the picture in the instructions...

I have this so far
for(int x=0; x<60; x++)
{
g.drawLine(10,10,10+x*(630/60),640)
}

6. ### iShater macrumors 604

Joined:
Aug 13, 2002
Location:
Chicagoland
#6
What are you getting?

Joined:
Aug 20, 2007
Location:
Houston, TX
#7
this...

8. ### lee1210 macrumors 68040

Joined:
Jan 10, 2005
Location:
Dallas, TX
#8
Edit: Nevermind, not a caching problem. You're getting exactly what you want.

Look at your loop more. Write down the coordinates you want to get, and what you do get:
You are drawing from:
(10,10) to:
(10,640),
(20,640),
(30,640),
...
(600,640)

Is this what you want?

-Lee

9. ### iShater macrumors 604

Joined:
Aug 13, 2002
Location:
Chicagoland
#9
So the concern is that you are not going all the way to the end of the screen? or that you are starting from the top left? this is what the formula you are using will do.

10. ### rolex54 thread starter macrumors 6502

Joined:
Aug 20, 2007
Location:
Houston, TX
#10
so what would I use to recreate this? (This is the task that is assigned in the lab sheet)
I don't know why he would give us that formula if it will not work to make this..

11. ### lee1210 macrumors 68040

Joined:
Jan 10, 2005
Location:
Dallas, TX
#11
http://www.mathsisfun.com/greatest-common-factor-tool.html
Or... math, will get you the GCD. Even without that, you just need to tweak your algorithm.

You're only moving where the line ends, not where it starts. You need to do both. I shouldn't be too bad. For one, you are starting in the upper left corner, (10,10). You need to start in the upper right corner, which is at (990,10). You may have to add and subtract to solve this.

Also, get off of the windows.

Use javac to compile your class on OS X from the terminal, then run:
appletviewer ./Lab05ast.html

Java is cross platform, and something like this does not require an IDE. When you get to the point of needing an IDE, there are others that are cross platform that you can use on OS X.

He gave you part of the solution, not the whole thing. It wouldn't be serving you if he did the legwork for you.

-Lee

12. ### iShater macrumors 604

Joined:
Aug 13, 2002
Location:
Chicagoland
#12
Lee, you are too nice again. He should have figured out that 10x10 is the left upper corner. God help us when these students work for us in the 10 years. (Us as in our generation )

13. ### lee1210 macrumors 68040

Joined:
Jan 10, 2005
Location:
Dallas, TX
#13
At least i didn't understand the coordinate system in awt and gave the wrong numbers. =) Er, maybe? I'm not even really sure yet.

-Lee

14. ### toddburch macrumors 6502a

Joined:
Dec 4, 2006
Location:
Katy, Texas
#14
I love doing other people's homework.

File size:
23.9 KB
Views:
113
15. ### toddburch macrumors 6502a

Joined:
Dec 4, 2006
Location:
Katy, Texas
#15
100 points for me.

File size:
56.9 KB
Views:
141
16. ### lee1210 macrumors 68040

Joined:
Jan 10, 2005
Location:
Dallas, TX
#16
Hooray, 100 pts for all!

File size:
470.4 KB
Views:
70
17. ### iShater macrumors 604

Joined:
Aug 13, 2002
Location:
Chicagoland
#17
You are cruel.

18. ### toddburch macrumors 6502a

Joined:
Dec 4, 2006
Location:
Katy, Texas
#18
I used to make these things in elementary school with a needle and thread on a piece of poster board. It was the only time anything I ever created "art-wise" made it to a show. It was displayed at the state capital (Juneau, Alaska) for a few weeks back in the late 60's. Who would have thunk 35+ years later, I'd be making them again, and this time a lot faster, and no sore finger from pushing the needle through.