Hello there!
I have been working with some folks on a solution to https://github.com/processing/processing/issues/5750 that includes a bunch of fun things (support for generics, lambdas, local type inference, move to more fully open source stack). Even if some of the new language feature support isn’t the most exciting for you, it helps a lot with keeping the internals of the system ready for the future. Some folks have been trying out the new version while Ben et all continue to work on the code review.
While this isn’t an official build or release, wanted to ask if the more adventurous here (like with mainline processing, no warranty / use at your own risk!) would also be willing to give https://github.com/sampottinger/processing a shot. There’s a link to downloads from the github page or you are welcome to build it yourself! If you encounter bugs, please write back here or, if you have a github account, file a ticket on the github issues page. Also, if it’s working for you, please feel free to write back here with your OS version.
Here’s a new sample of code that works under the new build that shows off the Java 8 language features (we also support most of the Java 11 API now too!):
/**
* Demonstration of Java 11 language features within Processing IDE.
*
* Sketch to demonstrate Java 11 language features within the Processing development environment
* including type inference and lambdas.
*/
import java.util.*;
List<ColoredCircle> circles;
/**
* Add a new circle to the global circles list.
*
* @param x The x coordinate for the new circle.
* @param y The y coordinate for the new circle.
* @param colorGen The strategy to use to generate colors.
*/
void addCircle(int x, int y, ColorGen colorGen) {
circles.add(new ColoredCircle(x, y, colorGen));
}
/**
* Processing-standard settings call to size sketch.
*/
void settings() {
circles = new ArrayList<>(); // Type inference
size(200, 200, FX2D);
smooth();
}
/**
* Initalize this sketch along with its colored circles.
*/
void setup() {
final color from = color(255, 255, 255);
final color to = color(0, 102, 153);
// Lambdas
addCircle(75, 75, (sec) -> { return lerpColor(from, to, abs(sin(sec))); });
addCircle(75, 125, (sec) -> { return lerpColor(from, to, abs(cos(sec))); });
addCircle(125, 125, (sec) -> { return lerpColor(from, to, abs(cos(sec / 2))); });
addCircle(125, 75, (sec) -> { return lerpColor(from, to, abs(sin(sec / 2))); });
}
/**
* Draw the circles within this sketch.
*/
void draw() {
background(255);
// New iteration
circles.forEach((x) -> {x.drawCircle();});
}
Thanks very much,
Sam