Sha256: b21a2944e8b68b25272b744a1d77a48b1a8c82d806e35beb2e57a46dec598858

Contents?: true

Size: 934 Bytes

Versions: 28

Compression:

Stored size: 934 Bytes

Contents

#! /usr/local/bin/ruby -w

require 'RMagick'
include Magick

img = Image.new(200,200)
img.compression = LZWCompression

bg = Image.read('plasma:fractal') {
    self.size = '200x200'
    }

gc = Draw.new
gc.stroke_width(2)
gc.stroke('black')
gc.fill('white')
gc.roundrectangle(0, 0, 199, 199, 8, 8)

gc.fill('black')
gc.circle(100,  45, 100,  25)
gc.circle( 45, 100,  25, 100)
gc.circle(100, 155, 100, 175)
gc.circle(155, 100, 175, 100)

gc.draw(img)

img.write('matte_fill_to_border_before.gif')

# Set the border color. Set the fuzz attribute so that
# the matte fill will fill the aliased pixels around
# the edges of the black circles.
img.border_color = 'black'
img.fuzz = 10
img = img.matte_fill_to_border(100, 100)

# Composite the image over a nice bright background
# so that the transparent pixels will be obvious.
img = bg[0].composite(img, CenterGravity, OverCompositeOp)

img.write('matte_fill_to_border_after.gif')
exit

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
rmagick-1.10.0 doc/ex/matte_fill_to_border.rb
rmagick-1.10.1 doc/ex/matte_fill_to_border.rb
rmagick-1.13.0 doc/ex/matte_fill_to_border.rb
rmagick-1.12.0 doc/ex/matte_fill_to_border.rb
rmagick-1.11.0 doc/ex/matte_fill_to_border.rb
rmagick-1.11.1 doc/ex/matte_fill_to_border.rb
rmagick-1.15.0 doc/ex/matte_fill_to_border.rb
rmagick-1.14.0 doc/ex/matte_fill_to_border.rb
rmagick-1.14.1 doc/ex/matte_fill_to_border.rb
rmagick-1.15.1 doc/ex/matte_fill_to_border.rb
rmagick-1.15.3 doc/ex/matte_fill_to_border.rb
rmagick-1.15.2 doc/ex/matte_fill_to_border.rb
rmagick-1.15.4 doc/ex/matte_fill_to_border.rb
rmagick-1.15.6 doc/ex/matte_fill_to_border.rb
rmagick-1.15.5 doc/ex/matte_fill_to_border.rb
rmagick-1.15.7 doc/ex/matte_fill_to_border.rb
rmagick-1.7.3 doc/ex/matte_fill_to_border.rb
rmagick-1.7.1 doc/ex/matte_fill_to_border.rb
rmagick-1.7.2 doc/ex/matte_fill_to_border.rb
rmagick-1.7.4 doc/ex/matte_fill_to_border.rb