Sha256: d85bf1c7e3d6bd79ab43704fa107d80afe6827a63a592f16dc889ae6f1b6fe49

Contents?: true

Size: 1.28 KB

Versions: 18

Compression:

Stored size: 1.28 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

# ignored if ImageMagick not configured with ZLIB
animation.compression = ZipCompression
#animation.animate
puts "...Writing rotating_text.miff"
animation.write("rotating_text.miff")
exit

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
rmagick-1.10.0 examples/rotating_text.rb
rmagick-1.10.1 examples/rotating_text.rb
rmagick-1.11.0 examples/rotating_text.rb
rmagick-1.11.1 examples/rotating_text.rb
rmagick-1.12.0 examples/rotating_text.rb
rmagick-1.13.0 examples/rotating_text.rb
rmagick-1.7.1 examples/rotating_text.rb
rmagick-1.7.2 examples/rotating_text.rb
rmagick-1.7.3 examples/rotating_text.rb
rmagick-1.7.4 examples/rotating_text.rb
rmagick-1.8.0 examples/rotating_text.rb
rmagick-1.8.1 examples/rotating_text.rb
rmagick-1.8.2 examples/rotating_text.rb
rmagick-1.8.3 examples/rotating_text.rb
rmagick-1.9.0 examples/rotating_text.rb
rmagick-1.9.1 examples/rotating_text.rb
rmagick-1.9.2 examples/rotating_text.rb
rmagick-1.9.3 examples/rotating_text.rb