require 'rubygems' require 'wx' require 'rubyonacid/factories/meta' require 'rubyonacid/factories/constant' require 'rubyonacid/factories/flash' require 'rubyonacid/factories/increment' require 'rubyonacid/factories/loop' require 'rubyonacid/factories/modulo' require 'rubyonacid/factories/random' require 'rubyonacid/factories/repeat' require 'rubyonacid/factories/sine' require 'rubyonacid/factories/skip' class MyApp < Wx::App WIDTH = 1920 HEIGHT = 1080 def on_init ARGV.each do |file_name| puts "Processing #{file_name}" @f = YAML.load_file(file_name) frame = Wx::Frame.new(nil, :size => [WIDTH, HEIGHT]) #Displays drawing. bitmap = Wx::Bitmap.new(WIDTH, HEIGHT) bitmap.draw do |surface| # surface.pen = black_pen surface.brush = Wx::BLACK_BRUSH surface.draw_rectangle(0, 0, WIDTH, HEIGHT) end 1000.times do bitmap.draw {|surface| render(surface)} end # bitmap.draw do |surface| # surface.text_foreground = Wx::Colour.new(255, 255, 255, 255) # # surface.text_background = Wx::Colour.new(0, 0, 0) # y = 0 # @f.to_yaml.split("\n").each do |line| # surface.draw_text(line, 0, y) # y += 10 # end # end bitmap.draw do |surface| surface.text_foreground = Wx::Colour.new(255, 255, 255, 255) surface.draw_text("©2009 Jay McGavren. Licensed under a Creative Commons Attribution-Share Alike 3.0 United States License: http://creativecommons.org/licenses/by-sa/3.0/us/", 10, HEIGHT - 20) end bitmap.save_file(file_name + ".png", Wx::BITMAP_TYPE_PNG) end exit end def render(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, 100).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 end app = MyApp.new app.main_loop