我想知道如何 运行 在 Eclipse 中处理代码

I want to know how you can run Processing Code in Eclipse

我的椭圆是用来画月亮的,其他所有表示填充的都是不同的颜色。基本上我的代码在黑色背景上为不同颜色的移动星星制作动画,下面有一个白色的月亮

void setup() { //only runs once    
  fullScreen();    
}    

void draw(){       
    {
    // black background
    fill (255);    

    // white circle(x,y,height,width)

    ellipse(800, 500, 500, 500);

    }
{
 //WHITE
  fill(0, 9);
  rect(0,0,width,height);
  fill(255); 
  noStroke();
  ellipse(random(width),random(height),3,3); 

  //GREEN
  fill(0,9);
  rect(0,0,width,height);    
  fill(0,250,9);     
  noStroke();    
  ellipse(random(width),random(height),5,5);

  //PURPLE
   fill(0,9);    
  rect(0,0,width,height);    
  fill(250,0,250);     
  noStroke();    
  ellipse(random(width),random(height),5,5);

  //BLUE      
   fill(0,9);    
  rect(0,0,width,height);    
  fill(0,255,255);     
  noStroke();    
  ellipse(random(width),random(height),5,5);
}

}

Processing 可以用作 Java 库,然后您可以从 Eclipse 中使用它,就像您可以使用任何其他 Java 库一样。

不过您必须稍微修改一下代码,因为您失去了处理编辑器为您所做的 "magic"。具体来说,您必须创建一个扩展 PApplet 的 class 并将您的代码放在那里。

在尝试移植完整的草图之前先做一些简单的工作。

这是一个例子:

import processing.core.PApplet;

public class MySketch extends PApplet {

    public void settings() {
        size(500, 500);
    }

    public void draw(){
        background(64);
        ellipse(mouseX, mouseY, 20, 20);
    }

    public static void main(String[] passedArgs) {
        String[] appletArgs = new String[] { "MySketch" };
        PApplet.main(appletArgs);
    }
}

无耻的自我推销:here 是将 Processing 用作 Java 库的指南。