日期:2014-05-20 浏览次数:20718 次
public static void main(String[] args) throws Exception { BufferedImage bi = new BufferedImage(500, 500, BufferedImage.TYPE_INT_RGB); Graphics2D graphics = (Graphics2D) bi.getGraphics(); graphics.setColor(Color.WHITE); graphics.fillRect(0, 0, 500, 500); graphics.setColor(Color.RED); for (int i = 0; i < 100000; i++) { int r = (int) ((1 + Math.sin(i)) * 150); int x = (int) (r * Math.cos(i) + 250); int y = (int) (r * Math.sin(i) + 175); Line2D point = new Line2D.Double(x, y, x, y); graphics.draw(point); } FileOutputStream fos = new FileOutputStream("c:\\test.jpg"); ImageIO.write(bi, "JPEG", fos); fos.flush(); fos.close(); }