Lab: Interactive Drawing
Take the new code from Basics of Input Processing and add it to the code as of the end of the textured triangle lab.
You can obtain the basics of a drawing program by answering these three questions from the "Coloring Time" section:
- At point (1) in the code, how can we check for the number keys 1-3? And how can we update the
color
field with a new color value? - At point (2), what is the purpose of the division and (in the next statement) the multiplication of the mouse coordinates?
- At point (3), try removing the
request_redraw()
call. What happens?
To complete the lab:
Extend the interactive drawing example from above however you like. For full credit, do two of the following:
- Draw three distinct types of shapes interactively by defining new "tools", e.g. by dragging with the mouse you can stretch out a rectangle. Some ideas:
- Filled rectangles
- Outlined rectangles
- Outlined polygons
- Bresenham-lines
- Circles
- Text
- Draw with partial transparency (check out the
Blend
type fromimageproc
), with keys to increase and decrease the alpha value of the current color. There are some hints on Zulip about this. - Something else, let me know what you have in mind!