Class: Magick::HatchFill
- Inherits:
-
Object
- Object
- Magick::HatchFill
- Defined in:
- lib/rmagick_internal.rb
Overview
Example fill class. Fills the image with the specified background color, then crosshatches with the specified crosshatch color. See Magick::Draw examples.
Instance Method Summary collapse
-
#fill(img) ⇒ Object
required.
-
#initialize(bgcolor, hatchcolor = 'white', dist = 10) ⇒ HatchFill
constructor
A new instance of HatchFill.
Constructor Details
#initialize(bgcolor, hatchcolor = 'white', dist = 10) ⇒ HatchFill
Returns a new instance of HatchFill.
1858 1859 1860 1861 1862 |
# File 'lib/rmagick_internal.rb', line 1858 def initialize(bgcolor, hatchcolor = 'white', dist = 10) @bgcolor = bgcolor @hatchpixel = hatchcolor.is_a?(Pixel) ? hatchcolor : Pixel.from_color(hatchcolor) @dist = dist end |
Instance Method Details
#fill(img) ⇒ Object
required
1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 |
# File 'lib/rmagick_internal.rb', line 1864 def fill(img) # required img.background_color = @bgcolor img.erase! # sets image to background color pixels = Array.new([img.rows, img.columns].max, @hatchpixel) @dist.step((img.columns - 1) / @dist * @dist, @dist) do |x| img.store_pixels(x, 0, 1, img.rows, pixels) end @dist.step((img.rows - 1) / @dist * @dist, @dist) do |y| img.store_pixels(0, y, img.columns, 1, pixels) end end |