Hi all,
Here's a challenge!
I'm working with a TDrawGrid. Give it, say, 10 rows and 10 columns, which means it has 100 cells. Now pick any two cells in the grid and draw a line that connects the centre of each.
What I want to know is, how can I tell what cells that line travels through? Anyone have any code snippets?
I want to use this algorithm to identify when a drawn indicator is moved around the grid and I only want to Invalidate the necessary cells to reduce flicker and drawing time.
I've made a good start on this, but it's a little unwieldy (my code requires 4 copies to handle the 4 different diagonal directions), plus my maths is thrown off because the line is drawn from the centre of the cell, and not from the nearest corners.
Many thanks!
Here's a challenge!
I'm working with a TDrawGrid. Give it, say, 10 rows and 10 columns, which means it has 100 cells. Now pick any two cells in the grid and draw a line that connects the centre of each.
What I want to know is, how can I tell what cells that line travels through? Anyone have any code snippets?
I want to use this algorithm to identify when a drawn indicator is moved around the grid and I only want to Invalidate the necessary cells to reduce flicker and drawing time.
I've made a good start on this, but it's a little unwieldy (my code requires 4 copies to handle the 4 different diagonal directions), plus my maths is thrown off because the line is drawn from the centre of the cell, and not from the nearest corners.
Many thanks!