Skip to content

Instantly share code, notes, and snippets.

View monkstone's full-sized avatar

Martin Prout monkstone

View GitHub Profile
@monkstone
monkstone / README.md
Created August 27, 2021 07:23
uniform_noise

UniformNoise by micycle

See source code You will need maven to build (no other dependencies)

@monkstone
monkstone / vector_list.rb
Created May 8, 2021 06:49
Adaptor for GMP
java_import 'java.util.ArrayList'
java_import 'processing.core.PVector'
class VectorList
attr_reader :list
def initialize
@monkstone
monkstone / de_jong.rb
Created January 31, 2021 12:48
PiCrate De Jong Attractor sketch
# frozen_string_literal: true
require 'picrate'
class DeJongAttractor < Processing::App
B = -2.3
attr_reader :x, :y, :xn, :yn, :timer
def settings
size(450, 450)
@monkstone
monkstone / two_color_rule.rb
Created November 19, 2020 10:35
Wolfram Two Color Rule
class TwoColorRule
attr_reader :rule, :colors
def initialize(number:, colors:)
@colors = colors
@rule = create_rule_from_int(number)
end
def apply_rule(input)
input.each_cons(3) do |triple|
left, center, right = *triple
@monkstone
monkstone / erb_template.rb
Created September 12, 2020 14:15
Shadertoy wrapper
require 'erb'
shadertoy = File.read(ARGV[0])
def shader_template
%(
#ifdef GL_ES
precision mediump float;
precision mediump int;
#endif
/*
* VLCJVideo
* VLCJ binding for Processing.
* http://github.com/linux-man/VLCJVideo
*
* Copyright (C) 2020 Caldas Lopes http://softlab.pt
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 3 of
/*
* VLCJVideo
* VLCJ binding for Processing.
* http://github.com/linux-man/VLCJVideo
*
* Copyright (C) 2020 Caldas Lopes http://softlab.pt
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 3 of
@monkstone
monkstone / gravitational_attraction.rb
Created July 30, 2020 20:04
Planetary Attraction (3D)
# frozen_string_literal: true
require 'picrate'
# Gravitational Attraction (3D)
# by Daniel Shiffman.
# Simulating gravitational attraction
# G ---> universal gravitational constant
# m1 --> mass of object #1
# m2 --> mass of object #2
# d ---> distance between objects
@monkstone
monkstone / decagon_grid.rb
Created July 5, 2020 14:56
Using lambda and grid in PiCrate
# frozen_string_literal: true
require 'picrate'
# Example of a grid of decagons with perlin noise after Lenny Herzog
class DecagonGrid < Processing::App
load_library :pdf
NOISE_STRENGTH = 80.0
THETA = 36
attr_reader :version, :save, :noise_generator
@monkstone
monkstone / solid_text.rb
Created July 3, 2020 11:38
Geomerative Solid Text
# frozen_string_literal: true
require 'picrate'
require 'geomerative'
# SolidText sketch, rubyists hate explicit get and set methods, using
# JRuby convention to replace them
class SolidText < Processing::App
attr_reader :em