import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.image.BufferedImage;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.image.BufferedImage;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import javax.imageio.ImageIO;
public class Homework25 {
public static void main(String[] args) {
BufferedImage i = new BufferedImage(600,600,1);
try {
Graphics2D g = (Graphics2D) i.getGraphics();
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);//画图去锯齿
g.setColor(Color.GRAY);//设置颜色
g.fillRect(0,0,600,600);//设置一个600X600的矩形
g.setColor(Color.WHITE);
g.fillOval(150, 150, 300, 300);//设置一个300X300的圆
g.setColor(Color.BLACK);
int x = 150;
int y = 150;
g.fillArc(x, y, 300, 300, 90, 180);
g.fillArc(225, y, 150, 150, 270, 180);//设置一个坐标为255,150,宽高为150X150,从270度开始逆时针旋转180度的扇形。
g.setColor(Color.WHITE);
g.fillArc(225,300, 150, 150, 90, 180);
g.fillOval(275, 200, 50, 50);
g.setColor(Color.BLACK);
g.fillOval(275, 350, 50, 50);
g.dispose();
ImageIO.write(i,"jpg",new FileOutputStream("e:/abc.jpg"));//在e盘生成abc.jpg文件
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
public static void main(String[] args) {
BufferedImage i = new BufferedImage(600,600,1);
try {
Graphics2D g = (Graphics2D) i.getGraphics();
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);//画图去锯齿
g.setColor(Color.GRAY);//设置颜色
g.fillRect(0,0,600,600);//设置一个600X600的矩形
g.setColor(Color.WHITE);
g.fillOval(150, 150, 300, 300);//设置一个300X300的圆
g.setColor(Color.BLACK);
int x = 150;
int y = 150;
g.fillArc(x, y, 300, 300, 90, 180);
g.fillArc(225, y, 150, 150, 270, 180);//设置一个坐标为255,150,宽高为150X150,从270度开始逆时针旋转180度的扇形。
g.setColor(Color.WHITE);
g.fillArc(225,300, 150, 150, 90, 180);
g.fillOval(275, 200, 50, 50);
g.setColor(Color.BLACK);
g.fillOval(275, 350, 50, 50);
g.dispose();
ImageIO.write(i,"jpg",new FileOutputStream("e:/abc.jpg"));//在e盘生成abc.jpg文件
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}