.. _lab3-drawing-polygons: Lab3: Drawing Polygons ###################### A square is a simple polygon. What would we do if we want to draw a polygon with more sides? Well, in the square, we draw a straight line then turned 90 degrees. What would you get if you turned 45 degrees and made more turns (like eight)? That figure would be an octagon which has eight sides. The problem with this idea is that you really do not know how big this object is going to be, unless you do some messy math! I will let you just use the same "step then turn some number of degrees" approach to draw the figure. How big it becomes is not something to worry about, but you need to play with the step size to get it looking reasonable. You will also need to experiment with the initial starting point for your drawing. Part 1: Build an Octagon ************************ Build a module that creates an octagon. Here is what mine looked like when I got it drawn: .. image:: Octagon.png :align: center Part 2: Build a circle ********************** Well, maybe not a real circle, but if you take a small number of steps, and turn a small number of degrees and do this enough times, it will end up looking like a circle. Here is mine: .. image:: Circle.png :align: center Think about how many degrees are in a full circle. You have to turn enough times to complete turning that number of degrees! If your steps are small enough, it will look like a circle, even if we know it is not really one! Part 3: A better Circle *********************** For the last part, I want you to do a little searching on the Internet for an example script that draws a good circle, using variables to control the radius and placement. Build a module out of the script you find (it should not be that hard to find one, I did in a few minutes). Make your module place the circle at some point, and be some radius. For this final program step, try to use all three of your modules to draw an octagon inside the simple circle, inside the really good circle. You will have to adjust the starting point for your first two figures, since they are not as nicely controlled as the last one should be! Call all three modules from your main script, as shown in the Scratch Modules lecture. Have fun with this! .. vim:filetype=rst spell: