Created
January 19, 2009 23:38
-
-
Save jstotz/49237 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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