File: pattern2.rb

package info (click to toggle)
librmagick-ruby 2.13.1-2
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 4,444 kB
  • ctags: 1,716
  • sloc: ansic: 16,755; ruby: 9,730; makefile: 16; sh: 12
file content (26 lines) | stat: -rw-r--r-- 598 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#! /usr/local/bin/ruby -w

require 'RMagick'

hat = Magick::Image.read("images/Flower_Hat.jpg").first
hat.resize!(0.25)

# Construct a pattern using the hat image
gc = Magick::Draw.new
gc.pattern('hat', 0, 0, hat.columns, hat.rows) {
    gc.composite(0, 0, 0, 0, hat)
}

# Set the fill to the hat "pattern." Draw an ellipse
gc.fill('hat')
gc.ellipse(150, 75, 140, 70, 0, 360)

# Create a canvas to draw on
img = Magick::Image.new(300, 150, Magick::HatchFill.new('white','lightcyan2',8))

# Draw the ellipse using the fill
gc.draw(img)

img.border!(1,1, "lightcyan2")
img.write('pattern2.gif')
exit