Sha256: 0d1e0b7de066b231bd2d2f95a7b00c4da535c6f5c026a8ec642236734b5c4e84

Contents?: true

Size: 736 Bytes

Versions: 4

Compression:

Stored size: 736 Bytes

Contents

# Ccreate a semi-transparent title for an image.

require 'rmagick'
include Magick

puts <<END_INFO

This example uses a semi-transparent background color to create a title.
View the resulting image by entering the command: display image_opacity.miff

END_INFO

balloons = Image.read('../doc/ex/images/Hot_Air_Balloons_H.jpg').first
legend = Image.new(160, 50) { self.background_color = '#ffffffc0' }

gc = Draw.new
gc.annotate(legend, 0, 0, 0, 0, 'Balloon Day!\\nFri May 2 2003') do
  self.gravity = CenterGravity
  self.stroke = 'transparent'
  self.fill = 'white'
  self.pointsize = 18
end

result = balloons.composite(legend, SouthGravity, OverCompositeOp)

puts '...Writing image_opacity.png'
result.write 'image_opacity.png'
exit

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rmagick-4.1.0.rc2 examples/image_opacity.rb
rmagick-4.1.0.rc1 examples/image_opacity.rb
rmagick-4.0.0 examples/image_opacity.rb
rmagick-3.2.0 examples/image_opacity.rb