Using loops and control statements to draw lines can
lead to many interesting desingns.
- Create the design in the left screen
capture of Fig 4.21. This design draws lines from the
top-left corner, fanning out the lines until they cover
the upper-left half of the panel. One approach is to
divide the width and height into an equal number
of steps (we found 15 steps worked well). The first
endpoint of a line will always be in the top-left
corner (0,0). The second endpoint can be found by
starting at the bottom-left corner and moving up
one vertical step and moving right one horizontal
step. Draw a line between the two endpoints. Continue
moving up and to the right one step to find each
successive endpoint. The figure should scale
accordingly as you resize the window.
- Modify your answer in part (a) to
have lines fan out from all four corners, as shown in
the right screen capture of Fig 4.21. Lines from
opposite corners should intersect along the middle.
Fig 4.21 - Lines fanning from a corner
This might be the hardest exercise you’ll get.
It’s very tricky. If you get this one right, you just
might have what it takes to become a first rate software
developer. If you need some help, click
here. The solution will
be available here and
here after
the end of next week’s class.