I am writing a Conway Game of Life implementation in C #. This is the code I use to draw the grid in my panel_Paint event. g is the graphics context.
for (int y = 0; y < numOfCells * cellSize; y += cellSize) { for (int x = 0; x < numOfCells * cellSize; x += cellSize) { g.DrawLine(p, x, 0, x, y + numOfCells * cellSize); g.DrawLine(p, 0, x, y + size * drawnGrid, x); } }
When I run my program, it does not respond until it finishes drawing a grid, which takes a few seconds at numOfCells = 100 and cellSize = 10. Removing all multiplication does this faster, but not by much.
Is there a better / more efficient way to draw my grid?
thanks
Joel source share