Sha256: 08d38c1375fdd727cea19a81237d9d80f412b2974d0978f907f9c9a65f7764d0

Contents?: true

Size: 740 Bytes

Versions: 5

Compression:

Stored size: 740 Bytes

Contents

# 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. 


def setup
    size 200, 200  
    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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ruby-processing-2.5.0 samples/processing_app/basics/color/reading/reading.rb
ruby-processing-2.4.4 samples/processing_app/basics/color/reading/reading.rb
ruby-processing-2.4.3 samples/processing_app/basics/color/reading/reading.rb
ruby-processing-2.4.2 samples/processing_app/basics/color/reading/reading.rb
ruby-processing-2.4.1 samples/processing_app/basics/color/reading/reading.rb