Last active
August 29, 2015 14:05
-
-
Save Jjunior130/dc10922633c775e9de44 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
class Pixel | |
attr_accessor :position, :color, :brightness, :shape, :states | |
def self.update_pixels | |
timestamp = Time.now | |
end | |
def initialize initial_position=Position.new (0,0,0), initial_color=Color.new 'black',+ | |
initial_brightness=Brightness.new 0.upto 1000 | |
begin | |
@position = initial_position | |
@color = initial_color | |
@brightness = initial_brightness | |
@shape = Square.new 1, 1 | |
@states = [].unshift [Time.now, self] | |
end | |
end | |
def state | |
"#{self}: | |
\tposition: #{@position} | |
\tcolor: #{@color} | |
\tbrightness: #{@brightness} | |
\tshape: #{@shape}" | |
end | |
def color= new_color | |
case new_color | |
when Color then | |
if @color.same_as? new_color then return @color | |
color = new_color | |
when | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment