The ellipse that I have is for drawing a moon and everything else that says fill is for different colors. Basically my code animates different colored moving stars on a black background with a white moon below
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 can be used as a Java library, and then you can use it from Eclipse just like you can use any other Java library.
You have to modify your code a bit though, since you lose out on the "magic" that the Processing editor does for you. Specifically, you have to create a class that extends PApplet
and put your code in there.
Get something simple working before you try porting over your full sketch.
Here's an example:
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);
}
}
Shameless self-promotion: here is a guide on using Processing as a Java library.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.