Skip to content

Instantly share code, notes, and snippets.

@supermomonga
Last active December 18, 2015 14:19
Show Gist options
  • Save supermomonga/5796190 to your computer and use it in GitHub Desktop.
Save supermomonga/5796190 to your computer and use it in GitHub Desktop.
require 'RMagick'
w = 64
h = 32
canvas = Magick::Image.new(w, h) {
self.format = 'png'
}
Magick::Draw.new.tap do |dr|
prng = Random.new
(0...w).each do |x|
(0...h).each do |y|
dr.fill "##{ prng.rand(16777216).to_s(16).rjust(6,'0') }"
dr.point(x, y)
end
end
dr.draw canvas
end
bin = canvas.to_blob
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment