Skip to content

Instantly share code, notes, and snippets.

View monkstone's full-sized avatar

Martin Prout monkstone

View GitHub Profile
@monkstone
monkstone / app.rb
Created October 18, 2014 14:38
Waiting for ruby-2.0 compatbility
require_relative 'helper_methods'
# The Processing module is a wrapper for JRubyArt
# Author:: Martin Prout (extends / re-implements ruby-processing)
module Processing
include_package 'processing.core' # imports the processing.core package.
include_package 'processing.event'
# This class is the base class the user should inherit from when making
# their own sketch.
#
grey_circles.rb:10 warning: ambiguous Java methods found, using background(int)
Exception in thread "Animation Thread" org.jruby.exceptions.RaiseException: (IOError) closed stream
at java.lang.Thread.getStackTrace(java/lang/Thread.java:1589)
at org.jruby.runtime.backtrace.TraceType$Gather.getBacktraceData(org/jruby/runtime/backtrace/TraceType.java:175)
at org.jruby.runtime.backtrace.TraceType.getBacktrace(org/jruby/runtime/backtrace/TraceType.java:39)
at org.jruby.RubyException.prepareBacktrace(org/jruby/RubyException.java:223)
at org.jruby.exceptions.RaiseException.preRaise(org/jruby/exceptions/RaiseException.java:215)
at org.jruby.exceptions.RaiseException.preRaise(org/jruby/exceptions/RaiseException.java:194)
at org.jruby.exceptions.RaiseException.<init>(org/jruby/exceptions/RaiseException.java:110)
at org.jruby.Ruby.newRaiseException(org/jruby/Ruby.java:3935)
@monkstone
monkstone / gist:e4fa6a436e59e20d32ec
Created December 4, 2014 06:53
Stack trace for failing sketch
grey_circles.rb:10 warning: ambiguous Java methods found, using background(int)
Exception in thread "Animation Thread" org.jruby.exceptions.RaiseException: (IOError) closed stream
at java.lang.Thread.getStackTrace(java/lang/Thread.java:1552)
at org.jruby.runtime.backtrace.TraceType$Gather.getBacktraceData(org/jruby/runtime/backtrace/TraceType.java:175)
at org.jruby.runtime.backtrace.TraceType.getBacktrace(org/jruby/runtime/backtrace/TraceType.java:39)
at org.jruby.RubyException.prepareBacktrace(org/jruby/RubyException.java:227)
at org.jruby.exceptions.RaiseException.preRaise(org/jruby/exceptions/RaiseException.java:215)
at org.jruby.exceptions.RaiseException.preRaise(org/jruby/exceptions/RaiseException.java:194)
at org.jruby.exceptions.RaiseException.<init>(org/jruby/exceptions/RaiseException.java:110)
at org.jruby.Ruby.newRaiseException(org/jruby/Ruby.java:3959)
@monkstone
monkstone / app.rb
Created January 8, 2015 15:35
refinements
# version without embedded or online
# This class is a thin wrapper around Processing's PApplet.
# Most of the code here is for interfacing with Swing,
# web applets, going fullscreen and so on.
require 'java'
require_relative '../ruby-processing/helper_methods'
require_relative '../ruby-processing/helpers/string'
require_relative '../ruby-processing/library_loader'
require_relative '../ruby-processing/config'
@monkstone
monkstone / .rp5rc
Created January 19, 2015 06:38
ruby-processing test case
{
"JRUBY": "false",
"PROCESSING_ROOT": "/home/tux/processing-3.0a5",
"X_OFF": 192,
"Y_OFF": 108
}
@monkstone
monkstone / .nbattrs
Created January 31, 2015 19:53
Netbeans templates for jruby_art
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE attributes PUBLIC "-//NetBeans//DTD DefaultAttributes 1.0//EN" "http://www.netbeans.org/dtds/attributes-1_0.dtd">
<attributes version="1.0">
<fileobject name="Sketch.rb">
<attr name="javax.script.ScriptEngine" stringvalue="freemarker"/>
<attr name="template" boolvalue="true"/>
</fileobject>
<fileobject name="SketchGL.rb">
<attr name="displayName" stringvalue="SketchGL.rb"/>
<attr name="javax.script.ScriptEngine" stringvalue="freemarker"/>
@monkstone
monkstone / box_fluid_demo.rb
Created April 6, 2015 06:52
Work in progress
require 'toxiclibs'
#
# <p>BoxFLuid demo combining 3D physics particles with the IsoSurface class to
# create an animated mesh with a fluid behaviour. The mesh is optionally created
# within a boundary sphere, but other forms can be created using a custom
# ParticleConstraint class.</p>
#
# <p>Dependencies:</p>
# <ul>
@monkstone
monkstone / test.rb
Created May 5, 2015 14:45
Some notes about getting and setting java parameters from ruby
require 'java'
java_import java.lang.System
jars = Dir[File.join('/home/tux/ruby-processing/lib', '**/*.jar')]
System.setProperty('java.class.path', jars.join(':'))
p System.getProperties['java.class.path']
libpath = System.getProperties['java.library.path']
libpath
System.setProperty('java.library.path', ['/home/tux/lib/linux64', libpath].join(':'))
@monkstone
monkstone / convert.rb
Last active May 12, 2017 10:27
Script to convert bare ruby-processing sketches from processing-2.0 to processing-3.0
# convert.rb
def titleize(str)
str.gsub(/::/, '/')
.gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
.gsub(/([a-z\d])([A-Z])/, '\1_\2')
.tr('-', '_')
.downcase
.gsub(/_id$/, '')
.gsub(/_/, ' ').capitalize
@monkstone
monkstone / custom_array.rb
Created June 4, 2015 10:31
Sketch using new ProxyLibrary library for JRubyArt
require 'forwardable'
# A custom Array created using forwardable (that can also access the PApplet pre,
# post and draw loops by extending our new LibraryProxy class. Also has access
# to custom background(int), fill(int) and stroke(int) methods.
class CustomArray < LibraryProxy
extend Forwardable
def_delegators(:@objs, :each, :<<)
include Enumerable