import java.awt.*;
import java.awt.geom.*;
import java.awt.image.*;
import java.io.*;
import java.util.*;
import javax.imageio.*;
public class Java2DTest21
{
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);
/* レンダリングヒントを設定 */
RenderingHints rh = new
RenderingHints(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
rh.put(RenderingHints.KEY_RENDERING,
RenderingHints.VALUE_RENDER_QUALITY);
gr.setRenderingHints(rh);
/* 描画色 */
gr.setColor(new Color(0xbb, 0xdd, 0xff));
/* 線のスタイルを設定 */
float dashPattern[] = {4.0f};
BasicStroke bs = new BasicStroke(2.0f,
BasicStroke.CAP_ROUND,
BasicStroke.JOIN_ROUND, 2.0f,
dashPattern, 0.0f);
gr.setStroke(bs);
/* 点線角丸四角を描画 */
RoundRectangle2D rr = new RoundRectangle2D.Double(
0.0, 0.0, 99.0, 99.0, 40.0, 40.0);
gr.draw(rr);
gr.dispose();
ImageIO.write(img, "jpg", new File("sample745a.jpg"));
}
}
出力画像(sample745a.jpg)
No comments:
Post a Comment