Class: FFFFFF::Util

Inherits:
Object
  • Object
show all
Defined in:
lib/0xffffff.rb

Class Method Summary collapse

Class Method Details

.create_image(width, height, color) {|tempfile| ... } ⇒ Object

Yields:

  • (tempfile)


53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# 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) ⇒ Object



49
50
51
# File 'lib/0xffffff.rb', line 49

def wait(sec)
  sleep(sec)
end