Sha256: f51554ef011c3056098fa7ca265cac12692eaee65182bf23189d3fbe8e29fd82

Contents?: true

Size: 943 Bytes

Versions: 10

Compression:

Stored size: 943 Bytes

Contents

#
# Extrusion. 
# 
# Converts a flat image into spatial data points and rotates the points
# around the center.
#

attr_reader :a, :values, :angle

def setup
  size(640, 360, P3D)
  @angle = 0
  @values = [] 
  no_fill
  # Load the image into a new array
  # Extract the values and store in an array
  @a = load_image("ystone08.jpg")
  a.load_pixels
  (0 ... a.height).each do |i|
    row = []
    (0 ... a.width).each do |j|
      pix = a.pixels[i*a.width + j]
      row << blue(pix).to_i
    end
    values << row
  end
end

def draw
  background(0)
  translate(width/2, height/2, -height/2)
  scale(2.0)
  
  # Update and constrain the angle
  @angle += 0.005
  rotate_y(angle)  
  
  # Display the image mass
  
  (0 ... a.height).step(4) do |i|
    (0 ... a.width).step(4) do |j|
      stroke(values[j][i], 255)
      line(j - a.width/2, i - a.height/2, -values[j][i], j - a.width/2, i - a.height/2, -values[j][i] - 10)
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
ruby-processing-2.6.3 samples/processing_app/basics/image/extrusion.rb
ruby-processing-2.6.2 samples/processing_app/basics/image/extrusion.rb
ruby-processing-2.6.1 samples/processing_app/basics/image/extrusion.rb
ruby-processing-2.6.0 samples/processing_app/basics/image/extrusion.rb
ruby-processing-2.5.1 samples/processing_app/basics/image/extrusion.rb
ruby-processing-2.5.0 samples/processing_app/basics/image/extrusion.rb
ruby-processing-2.4.4 samples/processing_app/basics/image/extrusion.rb
ruby-processing-2.4.3 samples/processing_app/basics/image/extrusion.rb
ruby-processing-2.4.2 samples/processing_app/basics/image/extrusion.rb
ruby-processing-2.4.1 samples/processing_app/basics/image/extrusion.rb