If you have developed it comfortably by classifying it properly with Processing, standard functions such as println ()
from an external Java class file (strictly speaking, the methods defined under processing.core.PApplet
) Can't be used! I thought, so I looked it up a little.
This is my environment now. I think that there is basically no problem in other environments.
Processing is a language / environment where you can easily code and learn in visual arts. It has been under development since 2001 and has contributed to improving software literacy in visual arts and art literacy in technology. Many students, artists, designers, researchers and hobbyists are now learning and prototyping with Processing. (Appropriate translation of the explanation of Official Site)
In other words, it's a very fun and wonderful environment where you can do art and prototyping quickly.
Currently, as far as I know, I import processing.core.PApplet
into an external Java class file where I want to use the function, and have an instance of PApplet (an instance of the base class / entry point class) inside the class. , I think it's a good idea to call the function from that instance. In other words, if you create a project with Test.pde
and create a class file called Human.java
in the same directory,
Test.pde
void setup() {
Human Oka = new Human();
}
void draw() { }
Human.java
public class Human {
public Human() {
println("ware umaretari"); //This makes me angry if println is not defined
}
}
,
Test.pde
void setup() {
Human Oka = new Human(this);
}
void draw() { }
Human.java
import processing.core.PApplet;
public class Human {
PApplet parent;
public Human(PApplet p) {
this.parent = p;
this.parent.println("ware umaretari");
}
}
That's good!
I will continue to do my best so that I can use it in a core way (?). I would appreciate it if you could tell me if there is a more clever way. By the way, I knew that I could call a method from the base class (Test class in this example), but could there be a more general way? I noticed that I was supposed to pass my instance in the constructor of ControlP5.
PApplet Javadocs Control P5 git repository
Recommended Posts