Class: Pixelart::ImageColorBar

Inherits:
Image
  • Object
show all
Defined in:
lib/pixelart/misc.rb

Constant Summary

Constants inherited from Image

Pixelart::Image::CHARS, Pixelart::Image::PALETTE8BIT, Pixelart::Image::RAINBOW_BLUE, Pixelart::Image::RAINBOW_GREEN, Pixelart::Image::RAINBOW_ORANGE, Pixelart::Image::RAINBOW_RED, Pixelart::Image::RAINBOW_VIOLET, Pixelart::Image::RAINBOW_YELLOW, Pixelart::Image::UKRAINE_BLUE, Pixelart::Image::UKRAINE_YELLOW

Instance Method Summary collapse

Methods inherited from Image

#[], #[]=, #_change_colors!, #_parse_color_map, #_parse_colors, #blur, calc_stripes, #change_colors, #change_palette8bit, #circle, #compose!, #crop, #flip, #grayscale, #height, #image, #led, #mirror, parse, parse_colors, parse_pixels, #pixels, #rainbow, read, #rotate_clockwise, #rotate_counter_clockwise, #save, #silhouette, #sketch, #spots, #spots_hidef, #stripes_horizontal, #transparent, #ukraine, #width, #zoom

Constructor Details

#initialize(colors, size: 24) ⇒ ImageColorBar

make a color bar

keep auto-zoom 24x or such - why? why not?


44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/pixelart/misc.rb', line 44

def initialize( colors, size: 24 )
  img = ChunkyPNG::Image.new( colors.size*size,
                              size,
                              ChunkyPNG::Color::WHITE ) # why? why not?

  colors = colors.map {|color| Color.parse( color ) }

  colors.each_with_index do |color,i|
    size.times do |x|
      size.times do |y|
        img[x+size*i,y] = color
      end
    end
  end

  super( img.width, img.height, img )
end