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, blob, #blur, calc_sample_steps, calc_stripes, #change_colors, #change_palette8bit, #circle, #compose!, convert, #crop, #flip_horizontally, #grayscale, #height, #image, inherited, #invert, #led, #left, #mirror, parse, parse_base64, parse_colors, parse_pixels, parse_pixels_strict, #pixels, #rainbow, read, #rotate_clockwise, #rotate_counter_clockwise, #sample, #sample_debug, #save, #silhouette, #sketch, #spots, #spots_hidef, #stripes_horizontal, subclasses, #to_blob, #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