Sha256: 4c71b5587aa01c267c0525a576a7ce75b1a2ceca5b06849642fcfe02ab77a1c2

Contents?: true

Size: 1.18 KB

Versions: 13

Compression:

Stored size: 1.18 KB

Contents

# Demonstrate the Draw#rotation= method by producing
# an animated MIFF file showing a rotating text string.

require 'rmagick'
include Magick

puts <<END_INFO
Demonstrate the rotation= attribute in the Draw class
by producing an animated image. View the output image
by entering the command: animate rotating_text.miff
END_INFO

text = Draw.new
text.pointsize = 28
text.font_weight = BoldWeight
text.font_style = ItalicStyle
text.gravity = CenterGravity

# Let's make it interesting. Composite the
# rotated text over a gradient fill background.
fill = GradientFill.new(100,100,100,100,'yellow','red')
bg = Image.new(200, 200, fill)

# The "none" color is transparent.
fg = Image.new(bg.columns, bg.rows) { self.background_color = 'none' }

# Here's where we'll collect the individual frames.
animation = ImageList.new

0.step(345,15) do |degrees|
  frame = fg.copy
  text.annotate(frame, 0,0,0,0, 'Rotating Text') do
    self.rotation = degrees
  end
  # Composite the text over the gradient filled background frame.
  animation << bg.composite(frame, CenterGravity, DisplaceCompositeOp)
end

animation.delay = 8

#animation.animate
puts '...Writing rotating_text.gif'
animation.write('rotating_text.gif')
exit

Version data entries

13 entries across 13 versions & 3 rubygems

Version Path
rmagick-windows-2.16.5 examples/rotating_text.rb
rmagick-windows-2.16.4 examples/rotating_text.rb
rmagick-windows-2.16.3 examples/rotating_text.rb
rmagick-windows-2.16.2 examples/rotating_text.rb
rmagick-windows-2.16.1 examples/rotating_text.rb
mdg-1.0.1 vendor/bundle/ruby/2.3.0/gems/rmagick-2.16.0/examples/rotating_text.rb
rmagick-2.16.0 examples/rotating_text.rb
rmagick-2.15.4 examples/rotating_text.rb
rmagick-2.15.3 examples/rotating_text.rb
rmagick-2.15.2 examples/rotating_text.rb
rmagick-2.15.1 examples/rotating_text.rb
rmagick-2.15.0 examples/rotating_text.rb
rmagick-2.14.0 examples/rotating_text.rb