Skip to content

Instantly share code, notes, and snippets.

View monkstone's full-sized avatar

Martin Prout monkstone

View GitHub Profile
@monkstone
monkstone / text_breaking_up.rb
Created December 21, 2009 16:34
Example Ruby Processing Sketch
require 'ruby-processing'
class TextBreakingUp < Processing::App
attr_accessor :sentence, :message
def setup
size 260, 200
fill 0
text_align LEFT
text_font create_font("Arial", 20, true)
@sentence = "click mouse to shake it up"
@monkstone
monkstone / stochastic.rb
Created December 31, 2009 08:50
Stochastic LSystem Plants in ruby processing
########################################################
# stochastic_test.rb
#
# Lindenmayer System in ruby-processing by Martin Prout
########################################################
require 'stochastic_plant'
class Stochastic_Test < Processing::App
attr_reader :stochastic, :stochastic1, :stochastic2
@monkstone
monkstone / isoceles.rb
Created April 20, 2010 18:52
Ruby Processing Context Free DSL sketch with custom primitive
load_library 'context_free'
def setup_the_spiral
@spiral= ContextFree.define do
############ Begin defining custom terminal, an isoceles triangle
class << self
define_method(:isoceles) do |some_options| # isoceles triangle
size, options = *self.get_shape_values(some_options)
rot = options[:rotation]
@app.rotate(rot) if rot
@monkstone
monkstone / default.rb
Created September 9, 2010 06:44
Experimental 3D context free dsl, in ruby processing
# A colorful animation of default.es
# the StructureSynth default script with wheel zoom feature
load_libraries :test_free
full_screen
attr_reader :xrot, :yrot, :zrot, :wheel, :col
def setup_the_spiral
@monkstone
monkstone / sunflow_hair.rb
Created October 1, 2010 09:30
Using sunflowAPIAPI in ruby-processing
# hair.rb NB: run this script directly with jruby
require 'library/sunflow_api/library/sunflow_api.jar'
require 'library/sunflow/library/sunflow.jar'
require 'library/sunflow/library/janino.jar'
class BasicHair
API = Java::Com::briansteen::SunflowAPIAPI
SMath = Java::Org::sunflow::math
@monkstone
monkstone / asynchronous_object.rb
Created October 16, 2010 07:42
Preston Lees multi-threaded star-field application modified to run on linux
# asynchronous_object.rb
#
# Copyright © 2009 Preston Lee. All rights reserved.
require 'thread'
class AsychronousObject
attr_reader :thread
attr_reader :update_frequency
@monkstone
monkstone / voronoi_app.rb
Created October 30, 2010 10:43
An application to "Create Voronoi Portraits"
load_libraries :mesh, :control_panel
import 'megamu.mesh.Voronoi'
attr_reader :voronoi, :img, :pixels, :ready, :upper, :show, :points, :xr, :yr, :lower, :lowskip, :highskip
def setup
size 500, 500
frame_rate 10
file = select_input "Choose Image File"
@img = load_image file
@monkstone
monkstone / grammar.rb
Created November 30, 2010 14:59
A Snake Kolam in ruby-processing demonstrates the use of PGraphicsPDF
#############################################################
# library/grammar.rb
# Non-stochastic grammar
# with unique premise/rules
############################################################
class Grammar
attr_accessor :axiom, :rules
def initialize axiom
@axiom = axiom
@monkstone
monkstone / star.svg
Created December 29, 2010 09:21
Simple star written in Amaya
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@monkstone
monkstone / PYP5.bsh
Created January 11, 2011 11:48
PYP5.xml
// This is a recorded macro. First, check over the
// commands to make sure this is what you intended. Then,
// save this buffer, and the macro should appear in the
// Macros menu.
new console.commando.CommandoDialog(view,"commando.PYP5");