File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Other JSE/JEE APIs and the fly likes 2D inconsistencies Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "2D inconsistencies" Watch "2D inconsistencies" New topic

2D inconsistencies

john price
Ranch Hand

Joined: Feb 24, 2011
Posts: 495

I tried to create a "tile" background for my program. It is not evenly spaced, as it should be. They are spaced 40 pixels apart, so it should be even. Some of the spaces are normal, but others are too small or too large. What am I doing wrong?

John Price aka cc11rocks

“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” (Mosher's Law of Software Engineering)
“If debugging is the process of removing bugs, then programming must be the process of putting them in.” (Edsger Dijkstra)
Rob Spoor

Joined: Oct 27, 2005
Posts: 20275

Why don't you use loops?
By only replacing the horizontal tiles with the first loop I already found one mistake in your code: line 53 fills horizontal_tile4 instead of vertical_tile4.
Replacing the vertical tiles with the second loop shows a change in the first argument from 160 to 200 (40 difference) to 220 (just 20 difference) to 260 (40 difference again).

I think that the combination of a) using the wrong tile, thereby missing one vertical tile, and b) the different gap in the vertical tiles, caused the strange results.

How To Ask Questions How To Answer Questions
john price
Ranch Hand

Joined: Feb 24, 2011
Posts: 495

Thank you very much!
John Price aka cc11rocks
I agree. Here's the link:
subject: 2D inconsistencies
jQuery in Action, 3rd edition