C++:Coordinates exercises

From Progzoo

The object DrawableRectangle takes four parameters.

  • The x coordinate of the top left corner
  • The y coordinate of the top left corner
  • The x coordinate of the bottom right corner
  • The y coordinate of the bottom right corner


Contents

Poland


We draw the flag of Poland with a white rectangle and a red rectangle.

Try the code shown - you will need to increase the height of each rectangle to get the picture right.

Image:Flagpoland.png

[Font] [Default] [Show] [Resize] [History] [Profile]


The object DrawableRectangle takes four parameters. The first two are the x and y coordinates of the top left of the rectangle. Note that y is the distance from the top of the picture.
We need to change the y parameter in the last call.

Austria


Try the code shown. It draws a big red rectangle then a smaller, white rectangle.

You will notice that the white rectangle is too high. We need to move it down.

Image:Flagaustria.png

[Font] [Default] [Show] [Resize] [History] [Profile]

Denmark


<img src="/img/flagdenmark.png" alt="Flag of Denmark"/>

We complete Denmark with three rectangles.

  • We draw a big red rectangle for the background.
  • We draw a wide, short rectangle for the horizontal bar of the cross.
  • We draw a tall thin rectangle for the vertical bar.

The Danish flag (Dannebrog) should have the cross shifted to the hoist side (the left) - our original program draws it in the center.

[Font] [Default] [Show] [Resize] [History] [Profile]

Madagascar

<img src="/img/madagascar.PNG" alt="Flag of Madagascar"/>

We draw the flag of Madagascar with a three rectangles.

The last rectangle, the green one is in the wrong place fix this.

[Font] [Default] [Show] [Resize] [History] [Profile]