Sha256: 4bbd1b62417d5d0a75eed911a975248d1315dcae7e24c4a1a49287084eb5f36d

Contents?: true

Size: 1.19 KB

Versions: 49

Compression:

Stored size: 1.19 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) { |degrees|
    frame = fg.copy
    text.annotate(frame, 0,0,0,0, "Rotating Text") {
        self.rotation = degrees
    }
    # Composite the text over the gradient filled background frame.
    animation << bg.composite(frame, CenterGravity, DisplaceCompositeOp)
}

animation.delay = 8

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

Version data entries

49 entries across 49 versions & 2 rubygems

Version Path
rmagick-2.13.4 examples/rotating_text.rb
rmagick-2.13.3 examples/rotating_text.rb
rmagick-2.13.3.rc1 examples/rotating_text.rb
rmagick-2.13.2 examples/rotating_text.rb
rdp-rmagick-0.0.0 examples/rotating_text.rb
rmagick-2.13.1 examples/rotating_text.rb
rmagick-2.12.2 examples/rotating_text.rb
rmagick-2.12.1 examples/rotating_text.rb
rmagick-2.12.0 examples/rotating_text.rb
rmagick-2.11.1 examples/rotating_text.rb
rmagick-2.10.0 examples/rotating_text.rb
rmagick-2.11.0 examples/rotating_text.rb
rmagick-1.15.10 examples/rotating_text.rb
rmagick-1.15.1 examples/rotating_text.rb
rmagick-1.15.0 examples/rotating_text.rb
rmagick-1.14.1 examples/rotating_text.rb
rmagick-1.14.0 examples/rotating_text.rb
rmagick-1.15.12 examples/rotating_text.rb
rmagick-1.15.11 examples/rotating_text.rb
rmagick-1.15.14 examples/rotating_text.rb