Sha256: fe0962379e82b71edab54fd64560da910403ff914b8afba2a6c62380ffda82bc

Contents?: true

Size: 862 Bytes

Versions: 4

Compression:

Stored size: 862 Bytes

Contents

require 'rvg/rvg'
include Magick

rvg = RVG.new(300, 300) do |canvas|
    canvas.background_fill = 'white'
    triangles = RVG::Pattern.new(16, 16).viewbox(0,0, 50,50) do |pat|
        pat.rect(50, 50).styles(:fill=>'darkblue')
        pat.polygon(0,0, 25,50, 50,0, 0,0).styles(:fill=>'yellow', :stroke=>'red')
    end

    canvas.ellipse(130, 60, 150, 75).styles(:stroke_width=>16, :fill=>'none', :stroke=>triangles)

    hat = Magick::Image.read('images/Flower_Hat.jpg').first

    hats = RVG::Pattern.new(hat.columns/4.0, hat.rows/4.0) do |pat|
        pat.image(hat, hat.columns/4.0, hat.rows/4.0)
    end

    canvas.g.translate(0, 150) do |grp|
        grp.ellipse(130, 60, 150, 75).styles(:fill=>hats)
    end

    canvas.rect(299, 299, 0, 0).styles(:fill=>'none', :stroke=>'blue')
    canvas.line(1, 150, 299, 150)
end

rvg.draw.write('rvg_pattern.gif')

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rmagick-1.8.0 doc/ex/rvg_pattern.rb
rmagick-1.8.1 doc/ex/rvg_pattern.rb
rmagick-1.8.2 doc/ex/rvg_pattern.rb
rmagick-1.8.3 doc/ex/rvg_pattern.rb