class MCDotArtMaker::Dot
Attributes
block[RW]
color[R]
x[R]
y[R]
Public Class Methods
new(color, x, y)
click to toggle source
# File lib/mc_dot_art_maker/dot.rb, line 7 def initialize(color, x, y) @color = color @x = x @y = y end
Private Class Methods
color_block_table()
click to toggle source
# File lib/mc_dot_art_maker/dot.rb, line 58 def color_block_table @color_block_table end
set_color_palette(cp)
click to toggle source
# File lib/mc_dot_art_maker/dot.rb, line 50 def set_color_palette(cp) @block_list = cp @color_block_table = @block_list.reduce({}) do |hash, block| hash.store(block.color,block) hash end end
Public Instance Methods
determine_block()
click to toggle source
def determine_block
(block_list)
# File lib/mc_dot_art_maker/dot.rb, line 19 def determine_block # comparitor = self.comparitor # block_distance_list = {} # block_list.each do |block| # block_distance_list[block] = comparitor.compare(block.color) # end # nearest_block = block_distance_list.min{ |x, y| x[1] <=> y[1] }[0] #[0]: key [1]: value # # self.block = nearest_block # nearest_block # clocest_block = block_list.select{ |block| # comparitor.compare(block.color) == 0 # }.first # raise(InternalError, "An error occured while determine clocest block...") if clocest_block.nil? # # @block = clocest_block @block = self.class.color_block_table[@color] end
to_rmagic_color()
click to toggle source
# File lib/mc_dot_art_maker/dot.rb, line 13 def to_rmagic_color # p "calc color :#{@color.r} #{@color.g} #{@color.b}" Magick::Pixel.new(@color.r*257, @color.g*257, @color.b*257) end