1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
| #!/usr/bin/env ruby
# encoding: utf-8
require 'rmagick'
def add_number(canvas, file, x, y, h)
image = Magick::ImageList.new(file).crop!(0, h, 63, 90)
canvas.composite!(image, x, y, Magick::OverCompositeOp)
end
number = "98765"
x, y = 1232, 1361
canvas = Magick::Image.read("base.png").first
number.split(//).each_with_index do |n, i|
xn = x + i * 87
yn = y + rand(0..3)
add_number(canvas, "w.png", xn, yn, n.to_i * 80)
end
add_number(canvas, "b.png", 1662, 1353, rand(0..720))
canvas.write("/tmp/moto.png")
|