Skip to content

Instantly share code, notes, and snippets.

@Jjunior130
Last active August 29, 2015 14:05
Show Gist options
  • Save Jjunior130/dc10922633c775e9de44 to your computer and use it in GitHub Desktop.
Save Jjunior130/dc10922633c775e9de44 to your computer and use it in GitHub Desktop.
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