Coordinates exercises
From Progzoo
The methodfillRect takes four parameters.
- x - the distance from the left
- y - the distance from the top
- width
- height
Contents |
Poland
<img src="/img/poland.PNG" alt="Flag of 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.
The method fillRect 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 x 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.
<img src="/img/flagaustria.png" alt="Flag of Austria"/>
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.
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.