import java.io.*;
import java.awt.*;
import java.awt.geom.*;
import java.awt.image.*;
import javax.imageio.*;
public class Java2DTest4
{
public static void main(String args[])
throws Exception
{
/* 角丸四角の画像を生成 */
BufferedImage img = new BufferedImage(
100, 100, BufferedImage.TYPE_INT_BGR
);
Graphics2D gr = img.createGraphics();
/* 背景を白で塗りつぶし */
gr.setColor(Color.WHITE);
gr.fillRect(0, 0, 100, 100);
/* 描画色 */
gr.setColor(Color.ORANGE);
/* 角丸四角を描画 */
RoundRectangle2D rr = new RoundRectangle2D.Double(
0.0, 0.0, 100.0, 100.0, 20.0, 20.0);
gr.fill(rr);
gr.dispose();
ImageIO.write(img, "png", new File("sample484a.png"));
}
}
出力画像(sample484a.png)
環境
JDK6 Upadate6(JDK1.6.0_06)
No comments:
Post a Comment