Processing Methods not found on Windows
ShadowfeindX opened this issue · 3 comments
I made simple test sketch.
def settings
size 400, 400
c = color rand 255
red c
end
def setup
sketch_title 'Test'
end
And when I ran it, um...
Unhandled Java exception: java.lang.NullPointerException
java.lang.NullPointerException: null
red at processing/core/PApplet.java:15154
invoke at java/lang/reflect/Method:-1
invokeDirectWithExceptionHandling at org/jruby/javasupport/JavaMethod.java:455
invokeDirect at org/jruby/javasupport/JavaMethod.java:316
settings at test.rb:3
invokeRuby at org/jruby/javasupport/proxy/JavaProxyConstructor.java:255
invoke at org/jruby/javasupport/proxy/JavaProxyConstructor.java:238
settings at org/jruby/proxy/processing/core/PApplet$Proxy1:-1
handleSettings at processing/core/PApplet.java:951
runSketch at processing/core/PApplet.java:10742
runSketch at processing/core/PApplet.java:10945
runSketch at processing/core/PApplet.java:10951
invoke at java/lang/reflect/Method:-1
invokeDirectWithExceptionHandling at org/jruby/javasupport/JavaMethod.java:440
tryProxyInvocation at org/jruby/javasupport/JavaMethod.java:625
invokeDirect at org/jruby/javasupport/JavaMethod.java:301
initialize at C:/JRuby92-x64/lib/ruby/gems/shared/gems/jruby_art-1.5.0/lib/jruby_art/app.rb:116
newInstance at org/jruby/RubyClass.java:997
call at org/jruby/RubyClass$INVOKER$i$newInstance.gen:-1
load_and_run_sketch at C:/JRuby92-x64/lib/ruby/gems/shared/gems/jruby_art-1.5.0/lib/jruby_art/runners/base.rb:46
invokeOther2:load_and_run_sketch at C_3a_/JRuby92_minus_x64/lib/ruby/gems/shared/gems/jruby_art_minus_1_dot_5_dot_0/lib/jruby_art/runners/C:/JRuby92-x64/lib/ruby/gems/shared/gems/jruby_art-1.5.0/lib/jruby_art/runners/run.rb:4
<main> at C_3a_/JRuby92_minus_x64/lib/ruby/gems/shared/gems/jruby_art_minus_1_dot_5_dot_0/lib/jruby_art/runners/C:/JRuby92-x64/lib/ruby/gems/shared/gems/jruby_art-1.5.0/lib/jruby_art/runners/run.rb:4
invokeWithArguments at java/lang/invoke/MethodHandle:-1
runScript at org/jruby/Ruby.java:852
runNormally at org/jruby/Ruby.java:771
runNormally at org/jruby/Ruby.java:789
runFromMain at org/jruby/Ruby.java:601
doRunFromMain at org/jruby/Main.java:415
internalRun at org/jruby/Main.java:307
run at org/jruby/Main.java:234
main at org/jruby/Main.java:206
Which I assume means that the gem, or JRuby itself, couldn't find the red method? This also happens for a few other methods such as green
, blue
, colorMode
, etc.
It's listed when I call find_method 'red'
and I can run a sketch that doesn't call red
such as loading an image or some such. And k9 --check
returns fine for me. I don't quite know what's going on.
@ShadowfeindX
Well your sketch is I think kind of illegal, the only purpose of settings as far as I know is to set
- size or full_screen
- mode (eg P2D) so
full_screen(P2D)
orsize 200, 200, P2D
- smooth in fact this is the only place to set smooth since processing-3
- pixel_density
Now if you want to define / use a random color you should just create it where you use it, if you want set a random color one time do it in setup (or define a constant)
def settings
size 400, 400
end
def setup
sketch_title 'Test'
end
def draw
background color(rand(255)) # pays to add brackets for nested args
end
OR
attr_reader :red
def settings
size 400, 400
end
def setup
sketch_title 'Test'
@red = color(rand(255)) # pays to add brackets for nested args
end
def draw
background red
end
I wasn't trying to create or define the color red. I was attempting to call the Processing function red
which should return the red value of an RGB color.
As for my sketch being illegal, yeah you're right. Changing it to this
def settings
size 800, 400
end
def setup
sketch_title 'Test'
c = color(rand(255))
p red c
end
Worked and did not throw an error.
Thanks!
@ShadowfeindX be sure to have a look at http://ruby-processing.github.io/JRubyArt/methods/color, there are hacks to get color to work on JRubyArt since java uses signed integers...