日期:2014-05-20  浏览次数:20718 次

JAVA的心
Java code

    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();
    }



------解决方案--------------------
然后可以结合那个透明的JFrame 搞个心满桌面飞
------解决方案--------------------
有点像 苹果 ...
------解决方案--------------------
Graphics2D graphics = (Graphics2D) bi.getGraphics();
=>
Graphics2D graphics = bi.createGraphics();