File: implode.rb

package info (click to toggle)
ruby-rmagick 6.0.1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 8,232 kB
  • sloc: cpp: 19,563; ruby: 17,147; sh: 88; javascript: 36; makefile: 13
file content (32 lines) | stat: -rw-r--r-- 722 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
require 'rmagick'

img = Magick::Image.read('images/Flower_Hat.jpg').first

legend = Magick::Draw.new
legend.stroke = 'transparent'
legend.fill = 'white'
legend.gravity = Magick::SouthGravity

frames = Magick::ImageList.new

implosion = 0.25
8.times do
  frames << img.implode(implosion)
  legend.annotate(frames, 0, 0, 10, 20, sprintf('% 4.2f', implosion))
  frames.alpha(Magick::DeactivateAlphaChannel)
  implosion -= 0.10
end

7.times do
  implosion += 0.10
  frames << img.implode(implosion)
  legend.annotate(frames, 0, 0, 10, 20, sprintf('% 4.2f', implosion))
  frames.alpha(Magick::DeactivateAlphaChannel)
end

frames.delay = 10
frames.iterations = 0
puts 'Producing animation...'

frames.write('implode.gif')
exit