New JavaX Construct: ifclass

Makes building compact programs even easier. Using ifclass, you can write functions for classes that may or may not exist without angering a compiler.

The reasoning behind this is that each JavaX program is “baked” individually, assembling both standard and custom functions (and classes) into a single compact Java source. Makes programs independent and easy to share & keep.

Example for ifclass: randomRect - a random rectangle maker that also takes an image for input (querying its width and height). However, if the (rather large) RGBImage class is not needed, it should not be pulled into the program. The following construct achieves this.

static Rect randomRect(int w, int h, int border, int rw, int rh) {
if (rw > w-border*2 || rh > h-border*2) null;
ret new Rect(random(border, w-border-rw), random(border, h-border-rh), rw, rh);

ifclass RGBImage
static Rect randomRect(RGBImage img, int rw, int rh) {
ret randomRect(img.w(), img.h(), 0, rw, rh);