62,616
社区成员
发帖
与我相关
我的任务
分享
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();
}
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++) {
double r = (1 + Math.sin(i)) * 150;
double x = r * Math.cos(i) + 250;
double y = 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();
}