ruby-processing / propane Goto Github PK
View Code? Open in Web Editor NEWA simpler ruby-processing for linux/Windows/MacOS?
Home Page: https://ruby-processing.github.io/propane
License: GNU General Public License v3.0
A simpler ruby-processing for linux/Windows/MacOS?
Home Page: https://ruby-processing.github.io/propane
License: GNU General Public License v3.0
OS X 10.11.5, though I expect this is universal
Installation should install the libraries
On a virgin system, installation does not install the libraries, because the installer script does not create the ~/.propane/Library/ directory, resulting in the cp -r erroring out.
either add
mkdir ~/.propane
mkdir ~/.propane/Libraries
after the propane installation instructions and before the samples/sound/video installation instructions, or, correct install scripts to create this directory hierarchy if missing
(jruby -v):
jruby 9.2.0.0 (2.5.0) 2018-05-24 81156a8 Java HotSpot(TM) 64-Bit Server VM 25.171-b11 on 1.8.0_171-b11 +jit [mswin32-x86_64]
(java -version):
java version "1.8.0_171"
Java(TM) SE Runtime Environment (build 1.8.0_171-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.171-b11, mixed mode)
(propane --version):
Propane version 2.7.2
JRuby version 9.2.0.0
(uname -a):
MINGW64_NT-10.0 DESKTOP-22BGKLK 2.8.0(0.309/5/3) 2017-05-19 13:17 x86_64 Msys
Hello!
I wanted to try out propane so I made a test script
require 'propane'
class Test < Propane::App
def settings
size 600, 600, P3D
end
def setup
sketch_title 'Test'
end
def draw
background 0
w = 10
grid(width, height) { |x, y|
rect x*w, y*w, w, w
}
end
end
Test.new
Unfortunately it gave me some errors like these (I changed the directory name to $PWD
because it was rather long and is actually my current working directory so...)
Unhandled Java exception: java.lang.UnsatisfiedLinkError: Can't load library: $PWD\natives\windows-amd64\\gluegen-rt.dll
java.lang.UnsatisfiedLinkError: Can't load library: $PWD\natives\windows-amd64\\gluegen-rt.dll
Unhandled Java exception: java.lang.UnsatisfiedLinkError: Can't load library: $PWD\natives\windows-amd64\\nativewindow_awt.dll
java.lang.UnsatisfiedLinkError: Can't load library: $PWD\natives\windows-amd64\\nativewindow_awt.dll
After some snooping I found lib/export.txt
and notice some things.
# stuff from file
application.windows32=core.jar,jogl-all.jar,gluegen-rt.jar,jogl-all-natives-windows-i586.jar,gluegen-rt-natives-windows-i586.jar
application.windows64=core.jar,jogl-all.jar,gluegen-rt.jar,jogl-all-natives-windows-amd64.jar,gluegen-rt-natives-windows-amd64.jar
# stuff from file
So, these files are exported, but actually the natives are not in the directory at all.
Only natives for mac and linux.
After downloading them and adding them manually I still get an error.
Then I noticed that the jogl-all
and gluegen-rt
have their version numbers in the filenames (like jogl-all-2.3.2.jar
), but not in the export file so I change the filenames and now it runs without the errors.
I'm not sure when exactly these files are downloaded by the gem or if there are any other references to these files so I can't offer a better solution other than doing it manually like this.
Let me know if there is any additional testing or some such I can do to help.
Cheers!
Hi
i have an issue when i try to run sketch that contain P3D
`
C:\Users\zaki\Desktop\ruby\Jruby>jruby P3.rb
Unhandled Java exception: java.lang.UnsatisfiedLinkError: Can't load library: C:\Users\zaki\Desktop\ruby\Jruby\natives\windows-amd64\gluegen-rt.dll
java.lang.UnsatisfiedLinkError: Can't load library: C:\Users\zaki\Desktop\ruby\Jruby\natives\windows-amd64\gluegen-rt.dll
loadLibrary at java/lang/ClassLoader:-1
load0 at java/lang/Runtime:-1
load at java/lang/System:-1
loadLibraryInternal at com/jogamp/common/jvm/JNILibLoaderBase.java:624
access$000 at com/jogamp/common/jvm/JNILibLoaderBase.java:63
loadLibrary at com/jogamp/common/jvm/JNILibLoaderBase.java:106
loadLibrary at com/jogamp/common/jvm/JNILibLoaderBase.java:487
loadLibrary at com/jogamp/common/os/DynamicLibraryBundle.java:421
run at com/jogamp/common/os/Platform.java:317
doPrivileged at java/security/AccessController:-2
at com/jogamp/common/os/Platform.java:287
run at com/jogamp/nativewindow/NativeWindowFactory.java:183
doPrivileged at java/security/AccessController:-2
at com/jogamp/nativewindow/NativeWindowFactory.java:180
run at com/jogamp/newt/NewtFactory.java:68
doPrivileged at java/security/AccessController:-2
at com/jogamp/newt/NewtFactory.java:65
initIcons at processing/opengl/PSurfaceJOGL.java:551
initFrame at processing/opengl/PSurfaceJOGL.java:137
initSurface at processing/core/PApplet.java:10451
runSketch at processing/core/PApplet.java:10338
runSketch at processing/core/PApplet.java:10516
runSketch at processing/core/PApplet.java:10522
invoke at java/lang/reflect/Method:-1
invokeDirectWithExceptionHandling at org/jruby/javasupport/JavaMethod.java:438
tryProxyInvocation at org/jruby/javasupport/JavaMethod.java:623
invokeDirect at org/jruby/javasupport/JavaMethod.java:299
initialize at C:/jruby-9.1.6.0/lib/ruby/gems/shared/gems/propane-2.1.0-java/lib/propane/app.rb:116
newInstance at org/jruby/RubyClass.java:994
call at org/jruby/RubyClass$INVOKER$i$newInstance.gen:-1
invokeOther11:new at P3.rb:17
<main> at P3.rb:17
invokeWithArguments at java/lang/invoke/MethodHandle:-1
runScript at org/jruby/Ruby.java:846
runNormally at org/jruby/Ruby.java:761
runNormally at org/jruby/Ruby.java:779
runFromMain at org/jruby/Ruby.java:592
doRunFromMain at org/jruby/Main.java:425
internalRun at org/jruby/Main.java:313
run at org/jruby/Main.java:242
main at org/jruby/Main.java:204`
i am using windows8.1
jruby==> C:\Users\zaki\Desktop\ruby\Jruby>jruby -v jruby 9.1.6.0 (2.3.1) 2016-11-09 0150a76 Java HotSpot(TM) 64-Bit Server VM 25.11 1-b14 on 1.8.0_111-b14 +jit [mswin32-x86_64]
java ==>C:\Users\zaki\Desktop\ruby\Jruby>java -version java version "1.8.0_111" Java(TM) SE Runtime Environment (build 1.8.0_111-b14) Java HotSpot(TM) 64-Bit Server VM (build 25.111-b14, mixed mode)
propane ==>C:\Users\zaki\Desktop\ruby\Jruby>propane -v Propane version 2.1.0 JRuby version 9.1.6.0
and thenk you :)
I use processing without a display all the time to create generative art. I usually make thousands of images and choose the ones I like. I use this guide: https://github.com/processing/processing/wiki/Running-without-a-Display
I tried doing the same thing with propane/jruby and no errors appear, but calling the save function does not actually save me any images. Can jruby save images under Xvfb or is there something special I need to do? Here is the test code I use:
class A < Propane::App
def setup
background(255,0,0)
save "a.jpg"
exit
end
end
A.new
I use jruby 9.1.8.0, java version "1.8.0_121" and propane 2.3.0
According to the docs:
Because of this method madness, Propane::App has a convenience method for searching through them. find_method('ellipse') will return a list of the method names that may match what you’re looking for: ‘ellipse’, ‘ellipseMode’, and ‘ellipse_mode’.
https://ruby-processing.github.io/propane/methods/processing_api
propane (2.3.0 java)
jruby -v
jruby 9.1.7.0 (2.3.1) 2017-01-11 68056ae Java HotSpot(TM) 64-Bit Server VM 25.102-b14 on 1.8.0_102-b14 +jit [darwin-x86_64]
uname -a
Darwin MacBook-Pro-6.local 14.5.0 Darwin Kernel Version 14.5.0: Wed Jul 29 02:26:53 PDT 2015; root:xnu-2782.40.9~1/RELEASE_X86_64 x86_64
java -version
java version "1.8.0_102"
Java(TM) SE Runtime Environment (build 1.8.0_102-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.102-b14, mixed mode)
this method should work from irb
Propane::App.find_method 'ellipse'
it fails with:
Propane::App.find_method 'ellipse'
NoMethodError: undefined method find_method' for Propane::App:Class Did you mean? define_method from org/jruby/RubyBasicObject.java:1653:in
method_missing'
no method found
NB: jdk9.0.4 from oracle.
Using custom propane (compiled with openjdk8 targeting jdk8) modified to use public runPropane() instead of protected runSketch() test sketch see https://github.com/ruby-processing/propane-examples/blob/master/contributed/jwishy.rb.
Sketch runs fine with jdk8
org.jruby.exceptions.RaiseException: (TypeError) illegal access on 'fireStateChanged': class org.jruby.javasupport.JavaMethod cannot access a member of class javax.swing.JSlider (in module java.desktop) with modifiers "protected"
at RUBY.initialize(/home/tux/.gem/ruby/2.3.0/gems/propane-2.6.5.pre-java/library/control_panel/control_panel.rb:28)
at RUBY.slider(/home/tux/.gem/ruby/2.3.0/gems/propane-2.6.5.pre-java/library/control_panel/control_panel.rb:134)
at home.tux.propane_minus_examples.contributed.jwishy.block in setup(/home/tux/propane-examples/contributed/jwishy.rb:20)
at RUBY.control_panel(/home/tux/.gem/ruby/2.3.0/gems/propane-2.6.5.pre-java/library/control_panel/control_panel.rb:170)
at home.tux.propane_minus_examples.contributed.jwishy.setup(/home/tux/propane-examples/contributed/jwishy.rb:17)
eg installation issue (just use this header and explain the problem as best you can)
Is it possible to do image drawing with irb? I realize that you have to subclass Propane::App normally, but if we want to do more experimentation in realtime, is there a way we can draw to the screen for each line we enter in irb?
NB: jdk9.0.4 from oracle.
Using custom propane (compiled with openjdk8 targeting jdk8) modified to use public runPropane() instead of protected runSketch() test sketch see https://github.com/ruby-processing/propane-examples/blob/master/processing_app/topics/shaders/monjori.rb.
Sketch runs fine with following warnings:-
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.jogamp.common.os.NativeLibrary$3 (file:/home/tux/.gem/ruby/2.3.0/gems/propane-2.6.5.pre-java/lib/gluegen-rt-2.3.2.jar) to method java.lang.ClassLoader.findLibrary(java.lang.String)
WARNING: Please consider reporting this to the maintainers of com.jogamp.common.os.NativeLibrary$3
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
eg installation issue (just use this header and explain the problem as best you can)
This issue was reported by @jtoy in a private email.
https://github.com/ruby-processing/propane-examples/blob/master/processing_app/basics/typography/letters.rb
Would be a suitable replacement, where we use keyboard? value in the draw loop instead of the apparently independent keyboard method (whose main advantage is to avoid cluttering up the draw method).
There is an issue jruby/jruby#4851 with sub-classing a java class and accessing a protected method with current jruby and jdk9. This is critical in the case our use of the protected runSketch()
method of PApplet to start a sketch. There is workaround see branch jdk9, however this is only a partial fix, and sketches using our control_panel
library with sliders don't work for the same issue of not being able to call a sub-classed protected method.
All keywords, function names, etc from Processing that exist in Propane have had their names converted to follow Ruby's snake_case convention. (e.g. mousePressed
--> mouse_pressed
)
I have found a few exceptions to this rule
All names should have snake_case equivalents
There are several names that don't have snake_case equivalents:
mouse_wheel
mouse_wheel
is not triggered when the mouse wheel is used, and mouseWheel
must be used instead
Doesn't work:
def mouse_wheel(event)
scroll_count = event.get_count
puts scroll_count
end
Works:
def mouseWheel(event)
scroll_count = event.get_count
puts scroll_count
end
display_width
, display_height
, pixel_width
and pixel_height
Doesn't work:
puts display_width
puts display_height
puts pixel_width
puts pixel_height
Works:
puts displayWidth
puts displayHeight
puts pixelWidth
puts pixelHeight
MacOS binaries should be in the macosx
folder, but the video library is in macosx64
folder
Re name the native binaries macosx64
folder to macosx
(in the library you downloaded to ~/.propane
folder)
You should note that the library loader is scheduled for a major overhaul so it is probably not worth issuing a temporary fix (as I have for JRubyArt)
I consistently receive a java.lang.reflect.InvocationTargetException
when running any propane sketch that does not have the P3D
renderer option. This issue appears to be that propane/processing is trying to define an icon for the applet that does not exist.
For example, from within the propane-examples contrib folder, when I run the following from the command line:
$ jruby animation.rb
I get the following stacktrace:
java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:567)
at processing.awt.PSurfaceAWT.setProcessingIcon(PSurfaceAWT.java:616)
at processing.awt.PSurfaceAWT.initFrame(PSurfaceAWT.java:456)
at processing.core.PApplet.initSurface(PApplet.java:10822)
at processing.core.PApplet.runSketch(PApplet.java:10710)
at processing.core.PApplet.runSketch(PApplet.java:10883)
at processing.core.PApplet.runPropane(PApplet.java:10897)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:567)
at org.jruby.javasupport.JavaMethod.invokeDirectWithExceptionHandling(JavaMethod.java:440)
at org.jruby.javasupport.JavaMethod.tryProxyInvocation(JavaMethod.java:625)
at org.jruby.javasupport.JavaMethod.invokeDirect(JavaMethod.java:301)
at org.jruby.java.invokers.InstanceMethodInvoker.call(InstanceMethodInvoker.java:36)
at org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:325)
at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:141)
at org.jruby.ir.interpreter.InterpreterEngine.processCall(InterpreterEngine.java:346)
at org.jruby.ir.interpreter.StartupInterpreterEngine.interpret(StartupInterpreterEngine.java:72)
at org.jruby.ir.interpreter.InterpreterEngine.interpret(InterpreterEngine.java:80)
at org.jruby.internal.runtime.methods.MixedModeIRMethod.INTERPRET_METHOD(MixedModeIRMethod.java:138)
at org.jruby.internal.runtime.methods.MixedModeIRMethod.call(MixedModeIRMethod.java:125)
at org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:336)
at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:151)
at org.jruby.RubyClass.newInstance(RubyClass.java:983)
at org.jruby.RubyClass$INVOKER$i$newInstance.call(RubyClass$INVOKER$i$newInstance.gen)
at org.jruby.internal.runtime.methods.JavaMethod$JavaMethodZeroOrNBlock.call(JavaMethod.java:309)
at org.jruby.java.proxies.ConcreteJavaProxy$NewMethod.call(ConcreteJavaProxy.java:151)
at org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:325)
at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:141)
at org.jruby.ir.interpreter.InterpreterEngine.processCall(InterpreterEngine.java:346)
at org.jruby.ir.interpreter.StartupInterpreterEngine.interpret(StartupInterpreterEngine.java:72)
at org.jruby.ir.interpreter.Interpreter.INTERPRET_ROOT(Interpreter.java:108)
at org.jruby.ir.interpreter.Interpreter.execute(Interpreter.java:95)
at org.jruby.ir.interpreter.Interpreter.execute(Interpreter.java:34)
at org.jruby.ir.IRTranslator.execute(IRTranslator.java:42)
at org.jruby.Ruby.runInterpreter(Ruby.java:861)
at org.jruby.Ruby.loadFile(Ruby.java:2953)
at org.jruby.runtime.load.LibrarySearcher$ResourceLibrary.load(LibrarySearcher.java:251)
at org.jruby.runtime.load.LibrarySearcher$FoundLibrary.load(LibrarySearcher.java:34)
at org.jruby.runtime.load.LoadService.load(LoadService.java:346)
at org.jruby.RubyKernel.loadCommon(RubyKernel.java:1037)
at org.jruby.RubyKernel.load(RubyKernel.java:1007)
at org.jruby.RubyKernel$INVOKER$s$load.call(RubyKernel$INVOKER$s$load.gen)
at org.jruby.internal.runtime.methods.JavaMethod$JavaMethodOneOrNBlock.call(JavaMethod.java:399)
at org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:346)
at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:172)
at DashE.invokeOther3:load(-e:1)
at DashE.RUBY$script(-e:1)
at java.base/java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:719)
at org.jruby.ir.Compiler$1.load(Compiler.java:94)
at org.jruby.Ruby.runScript(Ruby.java:849)
at org.jruby.Ruby.runNormally(Ruby.java:772)
at org.jruby.Ruby.runNormally(Ruby.java:790)
at org.jruby.Ruby.runFromMain(Ruby.java:602)
at org.jruby.Main.doRunFromMain(Main.java:415)
at org.jruby.Main.internalRun(Main.java:307)
at org.jruby.Main.run(Main.java:234)
at org.jruby.Main.main(Main.java:206)
Caused by: java.lang.NullPointerException
at processing.core.DesktopHandler.setIconImage(DesktopHandler.java:68)
... 62 more
Apart from this error message showing, the sketch does appear to run without issues within the applet (though no icon loads on the applet). So I believe this is a benign issue apart from this verbose and distracting stacktrace which shows on every run.
Oddly, this does not happen for propane sketches with the P3D
option called from the size
function on setup.
No error should show.
Obscure error shows.
Let me know if any further details are needed.
NB: jdk9.0.4 from oracle includes javafx jars.
Using custom propane (compiled with jdk9.0.4 targeting jdk8) modified to use public runPropane()
instead of protected runSketch()
test sketch see https://github.com/ruby-processing/propane-examples/blob/master/processing_app/basics/arrays/array_objects.rb.
Sketch runs fine with open-jdk8 (with javafx), and also with default renderer (and jdk9.0.4).
Exception in Application start method
java.lang.RuntimeException: Exception in Application start method
at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:973)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:198)
at java.base/java.lang.Thread.run(Thread.java:844)
Caused by: java.lang.NoSuchMethodError: com.sun.glass.ui.Screen.getRenderScale()F
at processing.javafx.PSurfaceFX$PApplicationFX.start(PSurfaceFX.java:249)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:919)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$11(PlatformImpl.java:449)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$9(PlatformImpl.java:418)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:417)
at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
at javafx.graphics/com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
at javafx.graphics/com.sun.glass.ui.gtk.GtkApplication.lambda$runLoop$11(GtkApplication.java:277)
... 1 more
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.