用鼠标做一个圆圈

时间:2015-10-29 01:52:03

标签: java

我正在尝试创建一个有圆圈的无限循环。无论鼠标移动到哪里,圆圈都会创建一条线并跟随。我创建了一个无限循环,但我不能让圆圈跟随鼠标。我应该使用mouseX()mouseY()

public static void main(String[] args)
{
    StdDraw.setScale(0,100); // initialize StdDraw, set scale to 0-100

    Double xCoor = 50.0; // set the xCoor(dinate) to 50
    Double yCoor = 50.0; // set the yCoor(dinate) to 50

    //StdDraw.filledCircle(50, 50, 10); // draw a filled circle in the middle of the screen.

    while(true) //infinite loop
    {
        int R = (int)(Math.random()*256); // R random color for Red component
        int G = (int)(Math.random()*256); // G random color for Green component
        int B = (int)(Math.random()*256); // B random color for Blue component

        StdDraw.show(1); // show the circles at a slower pace
        StdDraw.setPenColor(R, G, B); // set the pen color to all 3 components random
        StdDraw.filledCircle(50, 50, 10); // draw a filled circle in the center of the screen
    }

谢谢!

0 个答案:

没有答案