添加" snow"到图像

时间:2016-12-13 17:31:21

标签: java user-interface

需要弄清楚如何将降雪添加到图片的顶部并落到底部并在它碰到底部时自行移除。不知道该怎么做。我尝试过多种版本的雪,但他们没有工作。

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 个答案:

没有答案