(on OSX)
- Install Processing
- Move Processing.app/ to your preferred destination (mine is in
/Applications/
) - set scala classpath to include
your-install-location/Processing.app/Contents/Resources/Java/core/library/core.jar
. I created a little runner calledrun-sketch
that looks like this:
export PROCESSING_CLASS_PATH=$CLASSPATH:/Applications/Processing.app/Contents/Resources/Java/core/library/core.jar
scala -cp $PROCESSING_CLASS_PATH $1
In mySketch.scala
:
import processing.core._
object MySketch extends PApplet {
private var mySketch:MySketch = _
def main() = {
mySketch = new MySketch
val frame = new javax.swing.JFrame("MySketch")
frame.getContentPane().add(mySketch)
mySketch.init
//setting JFrame size directly, since it doesn't seem to work otherwise.
frame.setSize(600, 600)
frame.setVisible(true)
}
}
// Processing sketch code goes here!
class MySketch extends PApplet {
// Just like Processing!
override def setup() = {
}
override def draw() ={
}
}
// PApplet.main(Array[String]) <-- takes arguments and classname in Java
MySketch.main()
I can call ./run-sketch mySketch.scala
and view the sketch! Plus I can use my editor of choice and keep up to date with the latest version of Processing.
Horray!