Ruby on Acid: ConstantGenerator...
It seems obvious, in retrospect, that a little stability was needed with all this randomness…
@f.factory_pool << RubyOnAcid::ConstantFactory.new(rand)
In the image below, one of the Y coordinates is hooked up to a ConstantGenerator whose get_unit() always returns 0.5, hence, always halfway down the screen.
Similarly:
Read more...This is an XSD example from a normally stodgy tutorial site; were they trying for innuendo?
<xs:complexType name="jeans"> <xs:simpleContent> <xs:extension base="size"> <xs:attribute name="sex">Read more...
Ruby on Acid, continued...
Came up with an elaborate setup to step through all the permutations of an array of generators, and was getting so much repetition that I switched back to picking randomly. :P Dropped the increment and skip generators from the pool for this run because, frankly, they tended to make things ugly. I have a couple plans to “mute” or otherwise influence their effects, though, so I may be using them further in the future.
A YAML dump of the generators is embedded in each picture, so if you squint you can read what went into each.
Read more...MetaGenerator...
I’m getting an insane amount of variety out of very little code.
require 'rubygems'
require 'wx'
require 'rubyonacid/factories/meta'
require 'rubyonacid/factories/flash'
require 'rubyonacid/factories/increment'
require 'rubyonacid/factories/loop'
require 'rubyonacid/factories/random'
require 'rubyonacid/factories/sine'
require 'rubyonacid/factories/skip'
class MyApp < Wx::App
WIDTH = 480
HEIGHT = 480
def on_init
@f = RubyOnAcid::MetaFactory.new
@f.factories << RubyOnAcid::FlashFactory.new
@f.factories << RubyOnAcid::LoopFactory.new
@f.factories << RubyOnAcid::RandomFactory.new
@f.factories << RubyOnAcid::SineFactory.new
@f.factories << RubyOnAcid::SkipFactory.new
@resetter = RubyOnAcid::SkipFactory.new(0.999)
#Containing frame.
frame = Wx::Frame.new(nil, :size => [WIDTH, HEIGHT])
frame.show
#Displays drawing.
window = Wx::Window.new(frame, :size => [WIDTH, HEIGHT])
#Animate periodically.
t = Wx::Timer.new(self, 55)
evt_timer(55) {animate(window)}
t.start(33)
end
def animate(window)
window.paint do |surface|
surface.pen = Wx::Pen.new(
Wx::Colour.new(
@f.within(:red, 0, 255).to_i,
@f.within(:green, 0, 255).to_i,
@f.within(:blue, 0, 255).to_i,
@f.within(:alpha, 50, 255).to_i
),
@f.within(:width, 1, 5).to_i
)
surface.draw_line(
@f.within(:x, 0, WIDTH).to_i,
@f.within(:y, 0, HEIGHT).to_i,
@f.within(:x2, 0, WIDTH).to_i,
@f.within(:y2, 0, HEIGHT).to_i
)
end
@f.reset_assignments if @resetter.boolean(:reset)
end
end
app = MyApp.new
app.main_loop
Guess I'm freaking amazing, then...
Read more...We are all motivated by a keen desire for praise, and the better a man is, the more he is inspired to glory.
-Cicero