Sha256: 0d33a9dd2987f3f65142dc649cbe88014bde541e65819628d82a21128cd8e9d8
Contents?: true
Size: 1002 Bytes
Versions: 2
Compression:
Stored size: 1002 Bytes
Contents
# Explode # by Daniel Shiffman. # # Mouse horizontal location controls breaking apart of image and # Maps pixels from a 2D image into 3D space. Pixel brightness controls # translation along z axis. class Explode < Processing::App def setup size 640, 360, P3D @cell_size = 2 @img = load_image "eames.jpg" @columns = @img.width / @cell_size @rows = @img.height / @cell_size end def draw background 0 (0...@columns).each { |i| (0...@rows).each { |j| x = i * @cell_size + @cell_size / 2 y = j * @cell_size + @cell_size / 2 loc = x + y * @img.width c = @img.pixels[loc] z = (mouse_x / width.to_f) * brightness( @img.pixels[loc] ) - 20 push_matrix translate x + 200, y + 100, z fill c, 204 no_stroke rect_mode CENTER rect 0, 0, @cell_size, @cell_size pop_matrix } } end end Explode.new :title => "Explode"
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ruby-processing-1.0.11 | samples/processing_app/3D/image/explode.rb |
ruby-processing-1.0.10.1 | samples/processing_app/3D/image/explode.rb |