class FFFFFF::Util

Public Class Methods

create_image(width, height, color) { |tempfile| ... } click to toggle source
# File lib/0xffffff.rb, line 53
def create_image(width, height, color)
  png = ChunkyPNG::Image.new(width, height)
  color = ChunkyPNG::Color.from_hex('#' + color.to_s(16).rjust(6, '0'))

  width.times do |w|
    height.times do |h|
      png[w, h] = color
    end
  end

  tempfile = Tempfile.new("image")
  png.save(tempfile.path)

  yield tempfile

  tempfile.unlink
end
wait(sec) click to toggle source
# File lib/0xffffff.rb, line 49
def wait(sec)
  sleep(sec)
end