Skip to content

Instantly share code, notes, and snippets.

View monkstone's full-sized avatar

Martin Prout monkstone

View GitHub Profile
@monkstone
monkstone / euler_ball.rb
Last active February 12, 2016 07:18
Euler Integration sketch in JRubyArt after Ira Greenberg
# encoding: UTF-8
# module encapsulating run
module Runner
def run
move
render
bounds_collision
end
end
@monkstone
monkstone / jruby_art.svg
Last active December 19, 2015 06:32
schema
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
web = %w{#841B2D #c0c0c0 #ffd700}
names = %i{RUBY SILVER GOLD}
colours = names.zip(web).to_h
background color(colours[:GOLD])
# 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
@monkstone
monkstone / classic.rb
Created November 19, 2015 11:27
Monkey Patching in JRubyArt
# 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)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@monkstone
monkstone / bounce.rb
Created August 1, 2015 10:10
Live Coding Examples
# bounce.rb
class Bounce < Processing::App
BLUE = '#0000FF'
GREEN = '#00FF00'
RED = '#FF0000'
WHITE = '#FFFFFF'
BALL_SPEED = 5
BALL_SIZE = 32
@monkstone
monkstone / extensions.xml
Last active August 29, 2015 14:24
jbox2d maven
<?xml version="1.0" encoding="UTF-8"?>
<extensions>
<extension>
<groupId>io.takari.polyglot</groupId>
<artifactId>polyglot-ruby</artifactId>
<version>0.1.11</version>
</extension>
</extensions>
@monkstone
monkstone / steinberg.glsl
Last active August 29, 2015 14:22
GLSL filter experiment
// Original shader by RavenWorks
// Fake Floyd-Steinberg dithering
// https://www.shadertoy.com/view/4sjGRD
// Adapted for Ruby-Processing by Martin Prout <@monkstoneT>
#ifdef GL_ES
precision mediump float;
precision mediump int;
#endif
@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