Manic
Full Member
Offline
Posts: 123
Kinda live coding through reflect on two windows
Mar 18th , 2008, 12:21pm
This is just a very early proof of concept, so don't expect anything to fancy. I've been looking into the java.lang.reflect library to see if it would be possible to use it to create a sort of live coding environment. Well, it can... sort of. It's by no means perfect, and it'll require a thorough look through the pApplet docs, for example - the background command actually only accepts an integer, not a color, but it is possible. So, what this code does is; 1. Create an embedded applet in a new window, so you have to processing sketches at once 2. Create a callStack array, that contains the command name and the parameters as an Object[] array. 3. The embedded applet then calls everything on the callStack, through reflective programming from the parent app. You can click the larger embedded app to randomise the lines and color. So, yeah it's got a long way to go before its perfect, i'm sure if you gave it anything slightly harder to do, it'd choke immediately. It needs a lot of error handling and stuff to make it more user friendly, or perhaps a 'pre' function that makes sure that the parameters are passed in the correct format, or maybe creating a hash table from the pApplet's commands to ensure it gets it right first time. anyway, you can download the source here; http://www.graphicfilth.com/_2wndapplet.zip Download it, add to it, improve it (and post it back here!), do what ever you want. Martin (apologies for the messy coding)