class Magick::HatchFill
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.
Public Class Methods
new(bgcolor, hatchcolor='white', dist=10)
click to toggle source
# File lib/rmagick_internal.rb, line 1918 def initialize(bgcolor, hatchcolor='white', dist=10) @bgcolor = bgcolor @hatchpixel = Pixel.from_color(hatchcolor) @dist = dist end
Public Instance Methods
fill(img)
click to toggle source
# File lib/rmagick_internal.rb, line 1924 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