有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java将“雪”添加到图像中

需要弄清楚如何将落下的雪添加到图片的顶部,然后落到底部,并在落到底部时自行移除。不知道该怎么办。我试过加入多个版本的雪花,但都没用

import javax.swing.*; 
import java.awt.*;      
import java.awt.*;
public class SnowMan  extends JApplet

{

public void paint (Graphics frame)
{  
    final int MID = 150;    // middle of the snowman
    final int TOP = 50;     // top of the snowman
    frame.setColor (Color.cyan);
    frame.fillRect(0,0,300,250);
    frame.setColor (Color.blue);
    frame.fillRect (1, 175, 300, 50) ; 
    frame.setColor (Color.white);
    frame.fillOval (MID - 20, TOP, 40, 40);
    frame.fillOval (MID - 35, TOP + 35, 70, 50);
    frame.fillOval (MID - 50, TOP + 80, 100, 60);
    frame.setColor (Color.black); 
    frame.fillOval (MID - 10, TOP + 10, 5, 5);
    frame.fillOval (MID + 5, TOP + 10, 5, 5);
    frame.drawArc (MID - 10, TOP + 20, 20, 10, 190, 160);
    frame.drawLine (MID - 25, TOP + 60, MID - 50, TOP + 40);
    frame.drawLine (MID + 25, TOP + 60, MID + 55, TOP + 60);
    frame.drawLine (MID - 20, TOP + 5, MID + 20, TOP + 5);
    frame.fillRect (MID - 15, TOP - 20, 30, 25);
}

}


共 (0) 个答案