| Class | Magick::HatchFill |
| In: |
lib/RMagick.rb
|
| Parent: | Object |
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.
# File lib/RMagick.rb, line 1566
1566: def initialize(bgcolor, hatchcolor="white", dist=10)
1567: @bgcolor = bgcolor
1568: @hatchpixel = Pixel.from_color(hatchcolor)
1569: @dist = dist
1570: end
# File lib/RMagick.rb, line 1572
1572: def fill(img) # required
1573: img.background_color = @bgcolor
1574: img.erase! # sets image to background color
1575: pixels = Array.new([img.rows, img.columns].max, @hatchpixel)
1576: @dist.step((img.columns-1)/@dist*@dist, @dist) { |x|
1577: img.store_pixels(x,0,1,img.rows,pixels)
1578: }
1579: @dist.step((img.rows-1)/@dist*@dist, @dist) { |y|
1580: img.store_pixels(0,y,img.columns,1,pixels)
1581: }
1582: end