954,554 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Printing Grid bottom to top in frame

Dear all,

When printing a grid, for example a chess board, I was hoping it wouldn't have the same output as the console.

When I want the position to be grid[x][y] = 5, 5, it will place the counter in the bottom right corner in a 5x5 grid, (5,1) instead of the reverse in the top right corner.

I've used the usual inner for loop stepping through and drawing the line.

Anyone experienced this before and know how to deal with this?

Any advice would be much appreciated.

Thanks,
Cleo

StephNicolaou
Posting Whiz in Training
204 posts since Nov 2007
Reputation Points: 77
Solved Threads: 18
 

Because the graphics coordinates 00 is the upper right corner. simply subtract the coordinate you want to paint to from the over all height and use that as the y coordinate.

masijade
Industrious Poster
Moderator
4,253 posts since Feb 2006
Reputation Points: 1,471
Solved Threads: 494
 

Thank you for your response.

The height of the screen resolution or the grid?

Using the resolution seems a little unreliable as I would have to find the difference based on the grid size...which is going to be dynamically chosen.

For the grid, yes this would work for the position 5,5 of a grid size 5,5, but when the y position = 2, minus by the y grid size 5, this would result in -3, going off the grid.

Am I interpreting this correct?

StephNicolaou
Posting Whiz in Training
204 posts since Nov 2007
Reputation Points: 77
Solved Threads: 18
 

From the overall height of the desired image, of course.

Edit: And, of course, it is 5 - 2, not 2 - 5, in your example.

masijade
Industrious Poster
Moderator
4,253 posts since Feb 2006
Reputation Points: 1,471
Solved Threads: 494
 

Ah, your correction to my sum made a lot of sense.

I could minus the y co-ordinate from the grid size and the image would be in the right position for each in each case...

for x ..
for y ..
grid[x][gridSize - y]
//paint image here

Thanks for your ideas!
I will actually test this later :)

StephNicolaou
Posting Whiz in Training
204 posts since Nov 2007
Reputation Points: 77
Solved Threads: 18
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You