Replicate the grid example as above but use a different color and a different line style.
Write, compile, and run a simple program displaying a picture of your choice. Did it fit in your window? If not, what happened?
Make an 800-by-1000 Simple_window.
Put an 8-by-8 grid on the leftmost 800-by-800 part of that window (so that each square is 100 by 100).
Make the eight squares on the diagonal starting from the top left corner red (use Rectangle).
Find a 200-by-200-pixel image (JPEG or GIF) and place three copies ofit on the grid (each image covering four squares). If you can’t find an image that is exactly 200 by 200, use set_mask() to pick a 200-by-200 section of a larger image. Don’t obscure the red squares.
Add a 100-by-100 image. Have it move around from square to square when you click the “Next” button. Just put wait_for_button() in a loop with some code that picks a new square for your image.
Why don’t we “just” use a commercial or open-source graphics library directly?
About how many classes from our graphics interface library do you need to do simple graphics output?
What are the header files needed to use the graphics interface library?
What classes define closed shapes?
Why don’t we just use Line for every shape?
What do the arguments to Point indicate?
What are the components of Line_style?
What are the components of Color?
What is RGB?
What are the differences between two Lines and a Lines containing two lines?
What properties can you set for every Shape?
How many sides does a Closed_polyline defined by five Points have?
What do you see if you define a Shape but don’t attach it to a Window?
How does a Rectangle differ from a Polygon with four Points (corners)?
How does a Polygon differ from a Closed_polyline?
What’s on top: fill or outline?
Why didn’t we bother defining a Triangle class (after all, we did define Rectangle)?
How do you move a Shape to another place in a Window?
How do you label a Shape with a line of text?
What properties can you set for a text string in a Text?
What is a font and why do we care?
What is Vector_ref for and how do we use it?
What is the difference between a Circle and an Ellipse?
What happens if you try to display an Image given a file name that doesn’t refer to a file containing an image?
How do you display part of an Image?
How do you scale an Image?
Define a class Arrow, which draws a line with an arrowhead.
Define functions n(), s(), e(), w(), center(), ne(), se(), sw(), and nw(). Each takes a Rectangle argument and returns a Point. These functions define “connection points” on and in the rectangle. For example, nw(r) is the northwest (top left) corner of a Rectangle called r.
Define the functions from exercise 2 for a Circle and an Ellipse. Place the connection points on or outside the shape but not outside the bounding rectangle.
Write a program that draws a class diagram like the one in §10.6. It will simplify matters if you start by defining a Box class that is a rectangle with a text label.
Make an RGB color chart (e.g., search the Web for “RGB color chart”).
Define a class Regular_hexagon (a regular hexagon is a six-sided polygon with all sides of equal length). Use the center and the distance from the center to a corner point as constructor arguments.
Tile a part of a window with Regular_hexagons (use at least eight hexagons).
Define a class Regular_polygon. Use the center, the number of sides (>2), and the distance from the center to a corner as constructor arguments.
Draw a 300-by-200-pixel ellipse. Draw a 400-pixel-long x axis and a 300-pixel-long y axis through the center of the ellipse. Mark the foci. Mark a point on the ellipse that is not on one of the axes. Draw the two lines from the foci to the point.
Draw a circle. Move a mark around on the circle (let it move a bit each time you hit the “Next” button).
Draw the color matrix from §11.7.3, but without lines around each color.
Define a right triangle class. Make an octagonal shape out of eight right triangles of different colors.
"Tile" a window with small right triangles.
Do the previous exercise, but with hexagons.
Do the previous exercise, but using hexagons of a few different colors.
Define a class Poly that represents a polygon but checks that its points really do make a polygon in its constructor. Hint: You'll have to supply the points to the constructor.
Define a class Star. One parameter should be the number of points. Draw a few stars with differing numbers of points, differing line colors, and differing fill colors.
There is an Arc class in Graph.h. Find it and use it to define a box with rounded corners.