Skip to content

Instantly share code, notes, and snippets.

@jstotz
Created January 19, 2009 23:38
Show Gist options
  • Save jstotz/49237 to your computer and use it in GitHub Desktop.
Save jstotz/49237 to your computer and use it in GitHub Desktop.
require 'ruby-processing'
class Radiohead < Processing::App
load_libraries :opengl, :video
include_package "processing.opengl"
include_package "processing.video"
def setup
render_mode OPENGL
stroke_weight 1
@current_frame = 1
@total_frames = 1000
@movie = MovieMaker.new(self, width, height, "drawing.mov", 30, MovieMaker::ANIMATION, MovieMaker::HIGH)
end
def draw
background 0
translate(width/2, height/2)
translate(-150,-150)
scale(2)
rotateY(@current_frame/50.0);
puts "Rendering frame #{@current_frame}"
frame_data(@current_frame).each do |row|
x,y,z,intensity = row.split(',').collect {|x| x.to_f}
stroke(intensity*1.1, intensity*1.6, 200, 255)
line(x,y,z,x+1,y+1,z+1)
stroke(intensity*3.1, intensity*3.6, 150, 100)
line(x+100,y+100,z+100,x+101,y+101,z+101)
end
@movie.add_frame
advance_frame
end
def frame_data(frame)
load_strings("#{frame}.csv")
end
def advance_frame
if @current_frame == @total_frames
finish
else
@current_frame += 1
end
end
def finish
puts "Saving movie..."
@movie.finish
exit
end
end
Radiohead.new :title => "Radiohead", :width => 1024, :height => 768
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment