PHP:Flags with Rectangles Tutorial

From Progzoo
Jump to navigation Jump to search

You can use the GD php library at for these questions.


The flag of Libya is a simple green rectangle.

Try the program as it is given, then change it so that the green rectangle is 150 wide.
The function imagefilledrectangle will draw a filled rectangle

  • $g is the graphics area
  • ($x1,$y1) are the coordinates of the top left corner
  • ($x2,$y2) are the coordinates of the bottom right corner
  • $col is the color


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


The flag of France is blue, white and red. The code given draws only one of the three rectangles required, and it is in the wrong place.
Flag guide france.png

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


The flag of Germany is black, red and yellow.

Only one of the three rectangles has been drawn - and that one is in the wrong place.

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


  • The flag of Japan is a red circle on a white background.
  • The rectangle is 150 by 100.
  • The circle is in position 45,20, width and height are 60,60.
  • The dark lines are NOT part of the flag. They are shown as guides only.


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