JAVA的心

小绵羊 2011-10-12 10:25:12

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();
}
...全文
138 15 打赏 收藏 转发到动态 举报
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
huntor 2011-10-12
  • 打赏
  • 举报
回复
Graphics2D graphics = (Graphics2D) bi.getGraphics();
=>
Graphics2D graphics = bi.createGraphics();
小绵羊 2011-10-12
  • 打赏
  • 举报
回复
bohe_198878 2011-10-12
  • 打赏
  • 举报
回复
不懂求解
小绵羊 2011-10-12
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 tkd03072010 的回复:]

有点像 苹果 ...
[/Quote]

。。。确实很像
TKD03072010 2011-10-12
  • 打赏
  • 举报
回复
有点像 苹果 ...
阳明 to life 2011-10-12
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 x19881216 的回复:]

引用 3 楼 zhouyuqwert 的回复:

然后可以结合那个透明的JFrame 搞个心满桌面飞


。。。头象换的真快
[/Quote]
视觉疲劳了 换个造型
小绵羊 2011-10-12
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 zhouyuqwert 的回复:]

然后可以结合那个透明的JFrame 搞个心满桌面飞
[/Quote]

。。。头象换的真快
小绵羊 2011-10-12
  • 打赏
  • 举报
回复

r=1+sinθ

x = r * cosθ
y = r * sinθ
阳明 to life 2011-10-12
  • 打赏
  • 举报
回复
然后可以结合那个透明的JFrame 搞个心满桌面飞
shuwei003 2011-10-12
  • 打赏
  • 举报
回复
神马意思?
小绵羊 2011-10-12
  • 打赏
  • 举报
回复

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();
}
小绵羊 2011-10-12
  • 打赏
  • 举报
回复
看来木有几个人对这个有兴趣呀
皮特张 2011-10-12
  • 打赏
  • 举报
回复
咳咳,我是来顶贴的。
我嘞个去 2011-10-12
  • 打赏
  • 举报
回复
小羊童鞋
。。。。。。。。。。。
xiaona1047985204 2011-10-12
  • 打赏
  • 举报
回复
神马情况?很可爱的小羊

62,616

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧