Directly embedding Processing in Field (beta 10)
While Field likes to work with any Java-based library, for a long time now Field has given some special attention to Processing. Beta 10 builds on this relationship further, introducing Processing's version of Java directly into Field.
An "Applet" text transform
To install this new integration you'll need to enable the Processing plugin. Then go to the "other languages" tab of the main Palette — it's the tab that looks like a lambda — and make sure you enable 'JavaC'. You'll probably want to also check the "always initialize selected languages at startup" option:
Now we have a new "text transform" that let's us write Processing code directly in Field — not Python, not Java, but actual Processing code that goes through the PDE parser and comes out as an pseudo-applet.
(To make a text transform highlight some text in the editor, right click on it, select 'wrap in new text transform'. Then choose a transform that you want to apply from the right click menu).
Next steps — running the applet
Field has a completely different execution model from Processing. In Field everything is always running all the time — there's no global stop-compile-go button, but you can elect to start and stop individual pieces of code at will. This is one of the principle strengths of Field — you can have a Processing project running and "poke at it" or debug it live.
The processing text transform compiles your code and then assigns the applet to a new variable. By default, it's the name of the box of code you are writing in.
Field is now smart enough to do the right thing when you assign this "applet" to _r (see VisualElementLifecycles and remember to right click on the box an tell Field to "bridge to Processing environment).
This means that you can start and stop your "applet" using the usual Field techniques, and, while it's running, you can poke at it from elsewhere in Field. For example, in the code given above we have a variable called "spin" that's controlling the rotation of the cube. There's nothing to stop us writing and executing:
AnApplet.spin = 10 print AnApplet.spin # or even _ex.AnApplet.spin = (n for n in floatRange(0, 1, 100))
Assuming your calls to background don't trample on each other there's also nothing to stop you having many applets running "simultaneously" in the same window.
Wrap in Transform
If the extra chrome of the text transform is making you blue, don't miss the "wrap in transform" extension to Field.
Status
This part of Field is real new and the usual provisos about OpenEnded Groups relationship with Processing apply. Bug reports and inspiration welcome.


