Drawing Polar Grids
Explore how to subclass a grid to design polar grids with Ruby, focusing on rendering circular maze structures. Learn to calculate radii and angles, determine cell coordinates, and draw grid lines to generate visually structured circular mazes.
We'll cover the following...
We'll cover the following...
The PolarGrid class
The to_png method we’ve used up to this point isn’t going to help us much with polar grids, so let’s just subclass Grid and rewrite to_png to be what we need it to be. We'll create a new file named polar_grid.rb. We’ll add the Grid subclass and to_png method to our file.
Code explanation
Line 4: This new to_png method starts much like the old version, computing the size of our canvas.
Line 5: In this case, though, ...