Difference between revisions of "Tutorial/Flags"

From Progzoo
Jump to: navigation, search
Line 73: Line 73:
 
}
 
}
 
</answer>  
 
</answer>  
 +
<shell id="raster" lang='java'><![CDATA[
 +
import java.awt.image.BufferedImage;
 +
import java.awt.*;
 +
import java.io.File;
 +
import javax.imageio.ImageIO;
 +
 +
public class Raster{
 +
 +
QcQ
 +
 +
 +
  public static void main(String argv []){
 +
    BufferedImage image = new BufferedImage(QwidthQ,QheightQ, BufferedImage.TYPE_INT_ARGB);
 +
    Graphics2D g = image.createGraphics();
 +
    drawFlag(g);
 +
    g.dispose();
 +
    try {
 +
        File out = new File("flag.png");
 +
        ImageIO.write(image, "png", out);
 +
    }catch(Exception e){
 +
    System.err.println(e);
 +
    }
 +
  }
 +
}
 +
]]></shell> 
 
</question>
 
</question>

Revision as of 17:13, 24 October 2007

  • You may want to review: drawing and filling rectangles before tackling these questions.
  • You might want to try coordinates exercises if you are not comfortable with x,y coordinates.


Libya

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 wider. <img src="http://progzoo.net/img/flaglibya.png"/>



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

France

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. <img src="http://progzoo.net/img/flagfrance.png"/>



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