Skip to content
View HCallback.java
package hype;
@FunctionalInterface
public interface HCallback {
public void run(Object obj);
}
View magnetic_field.rb
load_library :hype
include_package 'hype'
module Hype
java_import 'hype.extended.layout.HGridLayout'
java_import 'hype.extended.behavior.HMagneticField'
java_import 'hype.extended.behavior.HSwarm'
end
attr_reader :pool, :pool_swarm, :field, :swarm
View MagneticField.java
/**
* Here is an example of a more tricky sketch to convert, first I exported to pure java (none that obfusctating processing
* crap), interestingly we can use a jdk8 lambda in place of a anonymous class for callback this is probably one way
* forward, although to be honest it may actually pay to create a JRuby extension to get more efficient operation.
*/
import processing.core.*;
import hype.*;
import hype.extended.layout.HGridLayout;
import hype.extended.behavior.HMagneticField;
View convert.rb
# convert.rb
VECLIBR = /\:(vecmath|fastmath)/
sketch = <<CODE
require 'propane'
class %s < Propane::App
%s
end
View euler_ball.rb
# encoding: UTF-8
# module encapsulating run
module Runner
def run
move
render
bounds_collision
end
end
View jruby_art.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View color_watch.rb
web = %w{#841B2D #c0c0c0 #ffd700}
names = %i{RUBY SILVER GOLD}
colours = names.zip(web).to_h
background color(colours[:GOLD])
View visualizer.rb
# Visualizer
# After http://dry.ly/ruby-music-visualizer by David Guttman
# Load minim and import the packages we'll be using
load_library :minim
import 'ddf.minim'
import 'ddf.minim.analysis'
attr_reader :beat, :current_ffts, :dim, :fft, :freqs, :input
attr_reader :fft_smoothing, :max_ffts, :minim, :scaled_ffts
View classic.rb
# Java::OrgJrubyExceptions::RaiseException
# (ArgumentError) wrong number of arguments calling `initialize` (3 for 0)
# RUBY.mouse_moved(mesh_doodle.rb:62)
attr_reader :prev, :p, :q, :rotation, :faces, :pos, :weight, :renderer
Face = Struct.new(:a, :b, :c)
class Vec3D # re-open the Vec3D class to add rotation functionality
def rotate_y(theta)
View ruby.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Something went wrong with that request. Please try again.