From 3b82919d3e08358d60c6ed450dbb9ae786486316 Mon Sep 17 00:00:00 2001 From: Dan Buch Date: Mon, 2 Jan 2012 00:32:34 -0500 Subject: [PATCH] Fresh start without too many jars --- .gitignore | 1 + bin/processing-commander | 13 + bin/prochome-check | 13 + build.xml | 29 ++ build/.gitkeep | 0 lib/amd64 | 1 + lib/x86_64/mbh-processing-practice.jar | Bin 0 -> 5065 bytes sketchbook/WaveGradient/WaveGradient.pde | 42 +++ sketchbook/libraries/.gitkeep | 0 sketchbook/modes/.gitkeep | 0 sketchbook/tools/.gitkeep | 0 .../processing/ProcessingRunner.java | 272 ++++++++++++++++++ 12 files changed, 371 insertions(+) create mode 100644 .gitignore create mode 100755 bin/processing-commander create mode 100755 bin/prochome-check create mode 100644 build.xml create mode 100644 build/.gitkeep create mode 120000 lib/amd64 create mode 100644 lib/x86_64/mbh-processing-practice.jar create mode 100644 sketchbook/WaveGradient/WaveGradient.pde create mode 100644 sketchbook/libraries/.gitkeep create mode 100644 sketchbook/modes/.gitkeep create mode 100644 sketchbook/tools/.gitkeep create mode 100644 src/com/meatballhat/processing/ProcessingRunner.java diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6b468b6 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.class diff --git a/bin/processing-commander b/bin/processing-commander new file mode 100755 index 0000000..373a5e5 --- /dev/null +++ b/bin/processing-commander @@ -0,0 +1,13 @@ +#!/bin/bash +TOP="$(dirname $(dirname $(readlink -f -- "$0")))" + +CP="$CLASSPATH" +CP="$TOP/lib/$(uname -a)/mbh-processing-practice.jar:$CP" +for procjar in "lib/core" "lib/pde" "java/lib/tools" "java/lib/rt" +do + CP="$PROCESSING_HOME/$procjar.jar:$CP" +done + +test -n "$DEBUG" && echo "DEBUG:CP=$CP" + +java -cp "$CP" com.meatballhat.processing.ProcessingRunner "$@" diff --git a/bin/prochome-check b/bin/prochome-check new file mode 100755 index 0000000..3932b0c --- /dev/null +++ b/bin/prochome-check @@ -0,0 +1,13 @@ +#!/bin/bash + +if [ -z "$PROCESSING_HOME" ]; then + cat >&2 < + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/build/.gitkeep b/build/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/lib/amd64 b/lib/amd64 new file mode 120000 index 0000000..4c36ca9 --- /dev/null +++ b/lib/amd64 @@ -0,0 +1 @@ +x86_64/ \ No newline at end of file diff --git a/lib/x86_64/mbh-processing-practice.jar b/lib/x86_64/mbh-processing-practice.jar new file mode 100644 index 0000000000000000000000000000000000000000..efc670e695fea9df21961956bd458a8618955f45 GIT binary patch literal 5065 zcmai&cTkh*_x9-sEFjXB&;$&D(5r;5^cL8N^bVmz5+L;A(mP9+t{8d|>BXf=B8c=} z6bMBTr3gv{&)vr-}B5pbDo*&I@h`HKR-r#q-4}YL|2H2u*AHoL_ZZ35gCzz zhVd;C9jK<**I^?llvG3vqY_!WU~?Yunt zZ9OF!otd1>EFG!$kttLvGwCo%C`k|Io5Za6G2>V|s3WlB$38?veR({pmn-}zvdhj9 z;U)I(#{aM4>OTrExV@i)y{D(Ez28sjZ}+i0!R{;^&@E0L&+o1X_9jwJoD@b?Fd|2W!$4W=@7nm(ffI3zY-9>ilZmpUsEAP?wiSQ;UdWQU!SBWaM!#p zxqniXP?C4jkzjlOq%7e=;y|e7Fd9&7%p3k5hakDKCLyB;Uw32dxw|2y`=NeN` zAx=M5wHCxER{5HBW%3cIz|lPh;np=eS8RuZ%2T84oZpBFOh;Ur8L) zCp=O#e?TEIxUZ){B=pRbw!}Cew#gbnBs6HOhL+jVx!0*Z&h#P+P%YFFUWI3a?d9T0 z%*1FF?>dt?l}D49fts?K7l`xtQmDBe$1>{Y)nG=XHq~RcDQ^hVmJ3&wKh4yKn4`p` zH<|80W#H+82Ia!C@B~3U12ax9V&8$U8%Ri#``$T_)_M@XS5x=-zY1LC! zbLvU1ZY0rAW|~g1>9cL;vgb@LJHJ$XE z)9%~#-edz6l)baq_3MNiiH#?9ODGgG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A@vsbg>=3gxcj%0U&FD^tCE^McMVH7 z{wv>PjT$~$8V`=9N1$U!PsJ)FNd_iTM zz}Mv1niFsk?R~6J@{$0YJSBJE5EEJ{Q;ajffF%Y3De%(|sGE{2_Qx=1uF}QNdj68! zyk*`OXgeTO#AI-|+PX2;OG8pp>tHumCr=x^ z#gsdbY--<``+zLWx7hiSqhzw5GIrgMQOna7Y}HQePKIl6wEsgMbz>DJ(-so{Lhsya z;XmM8fM7WztH(>St^;ys(q)EurCmfhl}~#er8iMquhLK?;r*ad!zWi%2HZ}_#m;OG z93mo_zj}D>SODw~79KW^tbX9(n1(dnn+c2WSmoO`ITNbV4O?NgJ``L|8Ssl4PP=1- z%IdH23qLF1em$8-%mD{UEbEjNSA8usj~~?JDi3yVXb}xdE z6CAr&;-WMbMG;z%SUta-bV@CeXB!x_YYlta_60qrWJvISup!MQ(~hzCO;{|gjI9e^ zHpy4A#lH`Js+y*t>%r=N#-n6|!6h9BCUAKv(PjH<$)pF_KxQ3dwIc7CI&-o(CB@k^_g*}UaRe@!Avbi(`$*lHQPo?tVY}~;S zSUYoU1a5#F>uepeQPqwHxYWf>380iqCq93rH_{^}VIuwilb-Lu;wsVmTi?1LFy}k> z`Pceu^7GwFM1=WM=x6Is9O&opU$L6+6TXFaUAEuJ&A*wyW;g#iR{nAP%w~Sh`xVRi z&rL)8KgiC%Yy6t+d>{1f>gtz+{v|#C#s8Z0{O9ugAMwBBK1O=v6yHWrUVbkw2fShU G_V<4#h5F(E literal 0 HcmV?d00001 diff --git a/sketchbook/WaveGradient/WaveGradient.pde b/sketchbook/WaveGradient/WaveGradient.pde new file mode 100644 index 0000000..67b728a --- /dev/null +++ b/sketchbook/WaveGradient/WaveGradient.pde @@ -0,0 +1,42 @@ +/** + * Wave Gradient + * by Ira Greenberg. + * + * Generate a gradient along a sin() wave. + */ + +float angle = 0; +float px = 0, py = 0; +float amplitude = 30; +float frequency = 0; +float fillGap = 2.5; +color c; + +int colorRange = 255; +int ncycles = 500; + +void setup() { + size(640, 360); + background(200); + noLoop(); +} + +void draw() { + for (int i =- ncycles; i < height+ncycles; i++){ + // Reset angle to 0, so waves stack properly + angle = 0; + // Increasing frequency causes more gaps + frequency+=.01; + for (float j = 0; j < width+ncycles; j++){ + py = i + sin(radians(angle)) * amplitude; + angle += frequency; + c = color(abs(py-i)*colorRange/amplitude, colorRange-abs(py-i)*colorRange/amplitude, j*((colorRange * 1.0)/(width+(int)(ncycles * 0.66)))); + // Hack to fill gaps. Raise value of fillGap if you increase frequency + for (int filler = 0; filler < fillGap; filler++){ + set(int(j-filler), int(py)-filler, c); + set(int(j), int(py), c); + set(int(j+filler), int(py)+filler, c); + } + } + } +} diff --git a/sketchbook/libraries/.gitkeep b/sketchbook/libraries/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/sketchbook/modes/.gitkeep b/sketchbook/modes/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/sketchbook/tools/.gitkeep b/sketchbook/tools/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/src/com/meatballhat/processing/ProcessingRunner.java b/src/com/meatballhat/processing/ProcessingRunner.java new file mode 100644 index 0000000..981afc9 --- /dev/null +++ b/src/com/meatballhat/processing/ProcessingRunner.java @@ -0,0 +1,272 @@ +package com.meatballhat.processing; + + +import java.io.File; +import java.io.IOException; +import java.io.PrintStream; + +import processing.app.Base; +import processing.app.Preferences; +import processing.app.SketchException; +import processing.app.RunnerListener; +import processing.app.Sketch; +import processing.core.PApplet; +import processing.mode.java.runner.*; + + +public class ProcessingRunner implements processing.app.RunnerListener { + static final String helpArg = "--help"; + static final String preprocArg = "--preprocess"; + static final String buildArg = "--build"; + static final String runArg = "--run"; + static final String presentArg = "--present"; + static final String sketchArg = "--sketch="; + static final String outputArg = "--output="; + static final String exportAppletArg = "--export-applet"; + static final String exportApplicationArg = "--export-application"; + static final String platformArg = "--platform="; + static final String bitsArg = "--bits="; + static final String preferencesArg = "--preferences="; + + static final int HELP = -1; + static final int PREPROCESS = 0; + static final int BUILD = 1; + static final int RUN = 2; + static final int PRESENT = 3; + static final int EXPORT_APPLET = 4; + static final int EXPORT_APPLICATION = 5; + + Sketch sketch; + + static public void main(String[] args) { + // Do this early so that error messages go to the console + Base.setCommandLine(); + // init the platform so that prefs and other native code is ready to go + Base.initPlatform(); + // make sure a full JDK is installed + Base.initRequirements(); + // run static initialization that grabs all the prefs + //Preferences.init(null); + // launch command line handler + new ProcessingRunner(args); + } + + public ProcessingRunner(String[] args) { + String sketchFolder = null; + String pdePath = null; // path to the .pde file + String outputPath = null; + String preferencesPath = null; + int platformIndex = PApplet.platform; // default to this platform + int platformBits = 0; + int mode = HELP; + + for (String arg : args) { + if (arg.length() == 0) { + // ignore it, just the crappy shell script + + } else if (arg.equals(helpArg)) { + // mode already set to HELP + + } else if (arg.equals(buildArg)) { + mode = BUILD; + + } else if (arg.equals(runArg)) { + mode = RUN; + + } else if (arg.equals(presentArg)) { + mode = PRESENT; + + } else if (arg.equals(preprocArg)) { + mode = PREPROCESS; + + } else if (arg.equals(exportAppletArg)) { + mode = EXPORT_APPLET; + + } else if (arg.equals(exportApplicationArg)) { + mode = EXPORT_APPLICATION; + + } else if (arg.startsWith(platformArg)) { + String platformStr = arg.substring(platformArg.length()); + platformIndex = Base.getPlatformIndex(platformStr); + if (platformIndex == -1) { + complainAndQuit(platformStr + " should instead be " + + "'windows', 'macosx', or 'linux'."); + } + } else if (arg.startsWith(sketchArg)) { + sketchFolder = arg.substring(sketchArg.length()); + File sketchy = new File(sketchFolder); + File pdeFile = new File(sketchy, sketchy.getName() + ".pde"); + pdePath = pdeFile.getAbsolutePath(); + + } else if (arg.startsWith(preferencesArg)) { + preferencesPath = arg.substring(preferencesArg.length()); + + } else if (arg.startsWith(outputArg)) { + outputPath = arg.substring(outputArg.length()); + + } else { + complainAndQuit("I don't know anything about " + arg + "."); + } + } + + if ((outputPath == null) && + (mode == PREPROCESS || mode == BUILD || + mode == RUN || mode == PRESENT)) { + complainAndQuit("An output path must be specified when using " + + preprocArg + ", " + buildArg + ", " + + runArg + ", or " + presentArg + "."); + } + + if (mode == HELP) { + printCommandLine(System.out); + System.exit(0); + } + + // --present --platform=windows "--sketch=/Applications/Processing 0148/examples/Basics/Arrays/Array" --output=test-build + + File outputFolder = new File(outputPath); + if (!outputFolder.exists()) { + if (!outputFolder.mkdirs()) { + complainAndQuit("Could not create the output folder."); + } + } + + // run static initialization that grabs all the prefs + // (also pass in a prefs path if that was specified) + Preferences.init(preferencesPath); + + if (sketchFolder == null) { + complainAndQuit("No sketch path specified."); + + } else if (outputPath.equals(pdePath)) { + complainAndQuit("The sketch path and output path cannot be identical."); + + } else if (!pdePath.toLowerCase().endsWith(".pde")) { + complainAndQuit("Sketch path must point to the main .pde file."); + + } else { + //Sketch sketch = null; + boolean success = false; + + try { + sketch = new Sketch(null, pdePath); + if (mode == PREPROCESS) { + success = true; // FIXME sketch.preprocess(new File(outputPath)) != null; + + } else if (mode == BUILD) { + success = true; // FIXME sketch.build(outputPath) != null; + + } else if (mode == RUN || mode == PRESENT) { + String className = "BUSTED"; // FIXME sketch.build(outputPath); + if (className != null) { + success = true; + Runner runner = new Runner(null, null); // FIXME new Runner(this, sketch); + runner.launch(true); // FIXME runner.launch(className, mode == PRESENT); + + } else { + success = false; + } + + } else if (mode == EXPORT_APPLET) { + if (outputPath != null) { + success = true; // FIXME sketch.exportApplet(outputPath); + } else { + String target = sketchFolder + File.separatorChar + "applet"; + success = true; // FIXME sketch.exportApplet(target); + } + } else if (mode == EXPORT_APPLICATION) { + if (outputPath != null) { + success = true; // FIXME sketch.exportApplication(outputPath, platformIndex, platformBits); + } else { + //String sketchFolder = + // pdePath.substring(0, pdePath.lastIndexOf(File.separatorChar)); + outputPath = + sketchFolder + File.separatorChar + + "application." + Base.getPlatformName(platformIndex); + success = true; // FIXME sketch.exportApplication(outputPath, platformIndex, platformBits); + } + } + System.exit(success ? 0 : 1); + + } catch (SketchException re) { + statusError(re); + + } catch (IOException e) { + e.printStackTrace(); + System.exit(1); + } + } + } + + public void statusNotice(String message) { + System.err.println(message); + } + + public void statusError(String message) { + System.err.println(message); + } + + public void statusError(Exception exception) { + if (exception instanceof SketchException) { + SketchException re = (SketchException) exception; + + // format the runner exception like emacs + //blah.java:2:10:2:13: Syntax Error: This is a big error message + String filename = sketch.getCode(re.getCodeIndex()).getFileName(); + int line = re.getCodeLine(); + int column = re.getCodeColumn(); + if (column == -1) column = 0; + // TODO if column not specified, should just select the whole line. + System.err.println(filename + ":" + + line + ":" + column + ":" + + line + ":" + column + ":" + " " + re.getMessage()); + } else { + exception.printStackTrace(); + } + } + + static void complainAndQuit(String lastWords) { + printCommandLine(System.err); + System.err.println(lastWords); + System.exit(1); + } + + static void printCommandLine(PrintStream out) { + out.println("Processing " + Base.VERSION_NAME + " rocks the console."); + out.println(); + out.println("--help Show this help text."); + out.println(); + out.println("--sketch= Specify the sketch folder (required)"); + out.println("--output= Specify the output folder (required and"); + out.println(" cannot be the same as the sketch folder.)"); + out.println(); + out.println("--preprocess Preprocess a sketch into .java files."); + out.println("--build Preprocess and compile a sketch into .class files."); + out.println("--run Preprocess, compile, and run a sketch."); + out.println("--present Preprocess, compile, and run a sketch full screen."); + out.println(); + out.println("--export-applet Export an applet."); + out.println("--export-application Export an application."); + out.println("--platform Specify the platform (export to application only)."); + out.println(" Should be one of 'windows', 'macosx', or 'linux'."); + out.println("--bits Must be specified if libraries are used that are"); + out.println(" 32- or 64-bit specific such as the OpenGL library."); + out.println(" Otherwise specify 0 or leave it out."); + out.println(); + out.println("--preferences= Specify a preferences file to use. Required if the"); + out.println(" sketch uses libraries found in your sketchbook folder."); + } + + public void startIndeterminate() { + } + + public void stopIndeterminate() { + } + + public void statusHalt() { + } + + public boolean isHalted() { + return false; + } +}