Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

executable file 46 lines (35 sloc) 1.222 kb
# 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
text =
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 =,100,100,100,"yellow","red")
bg =, 200, fill)
# The "none" color is transparent.
fg =, bg.rows) { self.background_color = "none" }
# Here's where we'll collect the individual frames.
animation =
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
puts "...Writing rotating_text.gif"
Jump to Line
Something went wrong with that request. Please try again.