Sha256: 59ceae5e1f87b44f515d3630c0b5a777c337e702241cbeca4804ff39268187e6

Contents?: true

Size: 852 Bytes

Versions: 9

Compression:

Stored size: 852 Bytes

Contents

require 'ruby-processing'

# An image is recreated from its individual component colors.
# The many colors of the image are created through modulating the 
# red, green, and blue values. This is an exageration of an LCD display. 

class Reading < Processing::App

  def setup
    no_stroke
    background 0
    
    c = load_image "cait.jpg"
    
    xoff, yoff = 0, 0
    p = 2
    pix = p * 3
    
    (c.width * c.height).times do |i|
    	
    	pixel = c.pixels[i]
    	
    	fill red( pixel ), 0, 0
    	rect xoff, yoff, p, pix
    	
    	fill 0, green( pixel ), 0
    	rect xoff+p, yoff, p, pix
    	
    	fill 0, 0, blue( pixel )
    	rect xoff+p*2, yoff, p, pix
    	
    	xoff += pix
    	if xoff >= (width-pix)
    		xoff = 0
    		yoff += pix
    	end
    end
    
  end
  
end

Reading.new :title => "Reading", :width => 200, :height => 200

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
ruby-processing-1.0.11 samples/processing_app/basics/color/reading/reading.rb
ruby-processing-1.0.10.1 samples/processing_app/basics/color/reading/reading.rb
ruby-processing-1.0.9 samples/processing_app/basics/color/reading/reading.rb
ruby-processing-1.0.4 samples/processing_app/basics/color/reading/reading.rb
ruby-processing-1.0.3 samples/processing_app/basics/color/reading/reading.rb
ruby-processing-1.0.5 samples/processing_app/basics/color/reading/reading.rb
ruby-processing-1.0.6 samples/processing_app/basics/color/reading/reading.rb
ruby-processing-1.0.7 samples/processing_app/basics/color/reading/reading.rb
ruby-processing-1.0.8 samples/processing_app/basics/color/reading/reading.rb