Created
October 10, 2009 21:20
-
-
Save brntbeer/207141 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env jruby | |
require "java" | |
include_class "processing.core.PApplet" | |
class Sketch < PApplet | |
def setup | |
size( 300, 300, P3D ) | |
no_stroke | |
color_mode RGB, 1 | |
@xmag = 0 | |
@ymag = 0 | |
@newXmag = 0 | |
@newYMag = 0 | |
end | |
def draw | |
background 0.5, 0.5, 0.45 | |
push_matrix | |
translate(width/2, height/2, -30) | |
@newXmag = mouseX/width.to_f * TWO_PI; | |
@newYmag = mouseY/height.to_f * TWO_PI; | |
diff = @xmag - @newXmag | |
if (diff.abs > 0.01) | |
@xmag -= diff/4.0 | |
end | |
diff = @ymag - @newYmag | |
if (diff.abs > 0.01) | |
@ymag -= diff/4.0 | |
end | |
rotateX -@ymag | |
rotateY -@xmag | |
scale(50) | |
begin_shape(QUADS) | |
fill(0, 1, 1); vertex(-1, 1, 1) | |
fill(1, 1, 1); vertex( 1, 1, 1) | |
fill(1, 0, 1); vertex( 1, -1, 1) | |
fill(0, 0, 1); vertex(-1, -1, 1) | |
fill(1, 1, 1); vertex( 1, 1, 1) | |
fill(1, 1, 0); vertex( 1, 1, -1) | |
fill(1, 0, 0); vertex( 1, -1, -1) | |
fill(1, 0, 1); vertex( 1, -1, 1) | |
fill(1, 1, 0); vertex( 1, 1, -1) | |
fill(0, 1, 0); vertex(-1, 1, -1) | |
fill(0, 0, 0); vertex(-1, -1, -1) | |
fill(1, 0, 0); vertex( 1, -1, -1) | |
fill(0, 1, 0); vertex(-1, 1, -1) | |
fill(0, 1, 1); vertex(-1, 1, 1) | |
fill(0, 0, 1); vertex(-1, -1, 1) | |
fill(0, 0, 0); vertex(-1, -1, -1) | |
fill(0, 1, 0); vertex(-1, 1, -1) | |
fill(1, 1, 0); vertex( 1, 1, -1) | |
fill(1, 1, 1); vertex( 1, 1, 1) | |
fill(0, 1, 1); vertex(-1, 1, 1) | |
fill(0, 0, 0); vertex(-1, -1, -1) | |
fill(1, 0, 0); vertex( 1, -1, -1) | |
fill(1, 0, 1); vertex( 1, -1, 1) | |
fill(0, 0, 1); vertex(-1, -1, 1) | |
end_shape | |
pop_matrix | |
end | |
end | |
JFrame = javax.swing.JFrame | |
frame = JFrame.new "RGB Cube" | |
applet = Sketch.new | |
frame.content_pane.add applet | |
frame.default_close_operation = JFrame::EXIT_ON_CLOSE | |
applet.init | |
frame.pack | |
frame.visible = true | |
Exception in thread "Animation Thread" processing/core/PApplet.java:1013:in `size': processing.core.PApplet$RendererChangeException: null (NativeException) | |
from processing/core/PApplet.java:959:in `size' | |
from sun/reflect/NativeMethodAccessorImpl.java:-2:in `invoke0' | |
from sun/reflect/NativeMethodAccessorImpl.java:39:in `invoke' | |
from sun/reflect/DelegatingMethodAccessorImpl.java:25:in `invoke' | |
from java/lang/reflect/Method.java:592:in `invoke' | |
from org/jruby/javasupport/JavaMethod.java:302:in `invokeWithExceptionHandling' | |
from org/jruby/javasupport/JavaMethod.java:263:in `invoke' | |
from org/jruby/java/invokers/InstanceMethodInvoker.java:72:in `call' | |
... 11 levels... | |
from processing/core/PApplet.java:1328:in `run' | |
from java/lang/Thread.java:613:in `run' | |
from :1 | |
Complete Java stackTrace | |
processing.core.PApplet$RendererChangeException | |
at processing.core.PApplet.size(PApplet.java:1013) | |
at processing.core.PApplet.size(PApplet.java:959) | |
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) | |
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) | |
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) | |
at java.lang.reflect.Method.invoke(Method.java:592) | |
at org.jruby.javasupport.JavaMethod.invokeWithExceptionHandling(JavaMethod.java:302) | |
at org.jruby.javasupport.JavaMethod.invoke(JavaMethod.java:263) | |
at org.jruby.java.invokers.InstanceMethodInvoker.call(InstanceMethodInvoker.java:72) | |
at org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:318) | |
at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:197) | |
at test.method__1$RUBY$setup(test.rb:9) | |
at testInvokermethod__1$RUBY$setupFixed0.call(test#setup) | |
at testInvokermethod__1$RUBY$setupFixed0.call(test#setup) | |
at org.jruby.internal.runtime.methods.DynamicMethod.call(DynamicMethod.java:138) | |
at org.jruby.RubyClass.finvoke(RubyClass.java:511) | |
at org.jruby.javasupport.util.RuntimeHelpers.invoke(RuntimeHelpers.java:419) | |
at org.jruby.javasupport.proxy.JavaProxyConstructor$2.invoke(JavaProxyConstructor.java:230) | |
at org.jruby.proxy.processing.core.PApplet$Proxy0.setup(Unknown Source) | |
at processing.core.PApplet.handleDraw(PApplet.java:1403) | |
at processing.core.PApplet.run(PApplet.java:1328) | |
at java.lang.Thread.run(Thread.java:613) | |
...internal jruby stack elided... | |
from processing.core.PApplet.size(PApplet.java:959) | |
from sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) | |
from sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) | |
from sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) | |
from java.lang.reflect.Method.invoke(Method.java:592) | |
from org.jruby.javasupport.JavaMethod.invokeWithExceptionHandling(JavaMethod.java:302) | |
from org.jruby.javasupport.JavaMethod.invoke(JavaMethod.java:263) | |
from org.jruby.java.invokers.InstanceMethodInvoker.call(InstanceMethodInvoker.java:72) | |
from org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:318) | |
from org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:197) | |
from test.method__1$RUBY$setup(test.rb:9) | |
from testInvokermethod__1$RUBY$setupFixed0.call(test#setup) | |
from testInvokermethod__1$RUBY$setupFixed0.call(test#setup) | |
from org.jruby.internal.runtime.methods.DynamicMethod.call(DynamicMethod.java:138) | |
from org.jruby.RubyClass.finvoke(RubyClass.java:511) | |
from org.jruby.javasupport.util.RuntimeHelpers.invoke(RuntimeHelpers.java:419) | |
from org.jruby.javasupport.proxy.JavaProxyConstructor$2.invoke(JavaProxyConstructor.java:230) | |
from org.jruby.proxy.processing.core.PApplet$Proxy0.setup(Unknown Source) | |
from processing.core.PApplet.handleDraw(PApplet.java:1403) | |
from processing.core.PApplet.run(PApplet.java:1328) | |
from java.lang.Thread.run(Thread.java:613) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment