Class Magick::HatchFill
In: lib/RMagick.rb
Parent: Object
Enum GeometryValue Stylable RVG\n[lib/rvg/clippath.rb\nlib/rvg/container.rb\nlib/rvg/deep_equal.rb\nlib/rvg/describable.rb\nlib/rvg/embellishable.rb\nlib/rvg/misc.rb\nlib/rvg/paint.rb\nlib/rvg/pathdata.rb\nlib/rvg/rvg.rb\nlib/rvg/stretchable.rb\nlib/rvg/stylable.rb\nlib/rvg/text.rb\nlib/rvg/transformable.rb\nlib/rvg/units.rb] Transformable Stretchable Embellishable Describable Duplicatable Comparable Image ImageList Enumerable Geometry OptionalMethodArguments HatchFill Draw lib/rvg/paint.rb lib/RMagick.rb ObjectData Application Pre_ObjectData_Descriptor Envelope Post_ObjectData_Descriptor IPTC Magick dot/m_14_0.png

Example fill class. Fills the image with the specified background color, then crosshatches with the specified crosshatch color. @dist is the number of pixels between hatch lines. See Magick::Draw examples.

Methods

fill   new  

Public Class methods

[Source]

      # File lib/RMagick.rb, line 1945
1945:    def initialize(bgcolor, hatchcolor="white", dist=10)
1946:       @bgcolor = bgcolor
1947:       @hatchpixel = Pixel.from_color(hatchcolor)
1948:       @dist = dist
1949:    end

Public Instance methods

[Source]

      # File lib/RMagick.rb, line 1951
1951:    def fill(img)                # required
1952:       img.background_color = @bgcolor
1953:       img.erase!                # sets image to background color
1954:       pixels = Array.new([img.rows, img.columns].max, @hatchpixel)
1955:       @dist.step((img.columns-1)/@dist*@dist, @dist) { |x|
1956:          img.store_pixels(x,0,1,img.rows,pixels)
1957:       }
1958:       @dist.step((img.rows-1)/@dist*@dist, @dist) { |y|
1959:          img.store_pixels(0,y,img.columns,1,pixels)
1960:       }
1961:    end

[Validate]