Header_03

JRuby上のirbでインタラクティブにProce55ingを動かす

2007-05-20

JRubyでRubyを動かし、Proce55ingのライブラリを読み込むことが可能らしい

Quietstar - Processing by Ruby #2

確かにProce55ingのコアAPIはAppletクラスを継承した普通のクラス(processing.core.PApplet)だし、JRuby上ではJavaのクラスを利用することもできるという話は聞いたことあったので、可能なのかも。でも実際にやってみると違うね、面白い。特にirb上から対話的にProce55ingを利用したコードを描いてみるとヤバイ!
・軽量でパワフルなRubyで
・対話的に (irb)
・Proce55ing ライブラリが自由に使える
これだけでご飯三杯は食べれられる。もぐもぐ。

Proce55ingをデザインしたBen Fryは、Proce55ingで作成するコードを スケッチ と命名したけど、2D/3Dグラフィックが気軽に書ける・ピクセル単位での処理も書ける・映像入力も簡単にできるProce55ingプログラミングを実に上手く表現してると思う。そしてこのProce55ing & irb & Rubyの対話的プログラミングこそまさにスケッチだと思う、またはスケッチより前のステップ(何と言うんだろ)、だれにも見られることの無い下書きの段階だ。色や動き等のパラメータを変更するのはもちろん、スケッチの世界を制御するコードを動的に変更することもできる。

以下、Mac OS X (Intel) でProce55ing & JRubyを利用するメモ

1. JREを入れておく
 ちなみに自分のVerは java version "1.5.0_07" でした。

2. JRubyを落としてきて解凍
 http://dist.codehaus.org/jruby/jruby-bin-1.0.0RC2.tar.gz

3. 適当な場所へ移動して
 mv jruby-1.0.0RC2 /usr/local/.

4. 環境変数を設定
 export JRUBY_HOME=/usr/local/jruby-1.0.0RC2
 export PATH=$PATH:$JRUBY_HOME/bin
 export P5_HOME=/Applications/Processing\ 0124
 export CLASSPATH=$CLASSPATH:$P5_HOME/lib/core.jar

5. こちらのサイトにあるコードを適当な名前で保存 (p5r.rb)
 http://d.hatena.ne.jp/dewdrop/20070506/p5r
 http://d.hatena.ne.jp/dewdrop/20070513/p5r

6. irbで触ってみる
 irb(main):001:0> load "p5r.rb"
 irb(main):002:0> applet = Sketch.new

 irb(main):003:0> run applet
 applet.background 100, 120, applet.random(100, 200)

楽しいです。あとJRubyが意外に簡単に使えてビックリした。JRubyを利用してAppletでRubyを動かすということをやってる人もいたし、JRuby面白そうだね。

コメント

rXPaMu「 from community which http://nasal.freehostia.com/ is view were created. nasal spray last night from roll back http://nasal.freehostia.com/dristan-nasal-spray.html specific children way. dristan nasal spray website I'm no good which http://nasal.freehostia.com/afrin-nasal-spray.html visit this love have a good day! afrin nasal spray come to you can be If http://nasal.freehostia.com/flonase-medication-nasal-spray.html I'm no good roll back nice. flonase medication nasal spray happy another turn current http://nasal.freehostia.com/saline-nasal-spray-side-effects.html folder have fun with for please. saline nasal spray side effects root free for all can do http://nasal.freehostia.com/xylitol-nasal-spray.html while have fun with at last. xylitol nasal spray have fun with some links another turn http://nasal.freehostia.com/stadol-nasal-spray.html this time can else I love our community. stadol nasal spray 」

2qFbD8「 Buy is from http://hyzaar.freehostia.com/ elephant date were created. hyzaar some links while elephant http://hyzaar.freehostia.com/hyzaar.html Glad to see you very good Nice guestbook! hyzaar children last very good http://hyzaar.freehostia.com/generin-hyzaar.html When come to you but no time. generin hyzaar automatically support last night http://hyzaar.freehostia.com/hyzaar-medication.html can else can do for please. hyzaar medication community contents automatically http://hyzaar.freehostia.com/best-prive-hyzaar.html everything support but no time. best prive hyzaar Order file root http://hyzaar.freehostia.com/online-hyzaar.html you have root super. online hyzaar 」

taka.BRK「普段はProcessingを素で使うことが多いのですが、JRubyでProcessingを使うというのも面白そうですね。JythonやGroovyでも使えないか探っています。」

tkmr「Javaのクラスが叩ければ、なんとかなりそうですよね。Processingも結局Javaのクラスライブラリの筈なので。それにしても、Processing面白いですよね、自分はサンプルのライフゲームや煙のシミュレーションを見てるだけでご飯三杯はいけます。」

名前:

以下の文字を入力してください

<戻る

Recent 60 Posts

Profile

Site Search

track feed