/** Convenience method for Python Mode */ protected void runSketch() { runSketch(new String[0]); }
runSketch(args, null);
/** * Convenience method for Python Mode to run an already-constructed sketch. * This makes it makes it easy to launch a sketch in Jython: * * <pre>class MySketch(PApplet): * pass * *MySketch().runSketch();</pre> */ protected void runSketch(final String[] args) { final String[] argsWithSketchName = new String[args.length + 1]; System.arraycopy(args, 0, argsWithSketchName, 0, args.length); final String className = this.getClass().getSimpleName(); final String cleanedClass = className.replaceAll("__[^_]+__\\$", "").replaceAll("\\$\\d+", ""); argsWithSketchName[args.length] = cleanedClass; runSketch(argsWithSketchName, this); }
/** * Convenience method so that PApplet.main("YourSketch", args) launches a * sketch, rather than having to wrap it into a String array, and appending * the 'args' array when not null. * @param mainClass name of the class to load (with package if any) * @param sketchArgs command line arguments to pass to the sketch's 'args' * array. Note that this is <i>not</i> the same as the args passed * to (and understood by) PApplet such as --display. */ static public void main(final String mainClass, final String[] sketchArgs) { String[] args = new String[] { mainClass }; if (sketchArgs != null) { args = concat(args, sketchArgs); } runSketch(args, null); }
public static void main(String... args) { Sketch sketch = new Sketch(); PApplet.runSketch(new String[]{"ch.bildspur.postfx.Sketch "}, sketch); } }