Sha256: 0a54b772638010ad41780697494de3aff1bb333013e1730d8f408f0720439c0e

Contents?: true

Size: 1.8 KB

Versions: 15

Compression:

Stored size: 1.8 KB

Contents

require 'rvg/rvg'

rvg = Magick::RVG.new(525, 270) do |canvas|
    canvas.background_fill = 'white'
    canvas.rect(524, 269).styles(:fill=>'none', :stroke=>'blue', :stroke_width=>1)

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

    canvas.image(hat, 100, 75, 25, 40).preserve_aspect_ratio('none')
    canvas.rect(100, 75, 25, 40).styles(:fill => 'none', :stroke => 'blue')

    canvas.image(hat, 100, 75, 150, 40).preserve_aspect_ratio('xMinYMin', 'meet')
    canvas.rect(100, 75, 150, 40).styles(:fill => 'none', :stroke => 'blue')

    canvas.image(hat, 100, 75, 275, 40).preserve_aspect_ratio('xMidYMid', 'meet')
    canvas.rect(100, 75, 275, 40).styles(:fill => 'none', :stroke => 'blue')

    canvas.image(hat, 100, 75, 400, 40).preserve_aspect_ratio('xMaxYMax', 'meet')
    canvas.rect(100, 75, 400, 40).styles(:fill => 'none', :stroke => 'blue')

    canvas.image(hat, 100, 75, 150, 155).preserve_aspect_ratio('xMinYMin', 'slice')
    canvas.rect(100, 75, 150, 155).styles(:fill => 'none', :stroke => 'blue')

    canvas.image(hat, 100, 75, 275, 155).preserve_aspect_ratio('xMidYMid', 'slice')
    canvas.rect(100, 75, 275, 155).styles(:fill => 'none', :stroke => 'blue')

    canvas.image(hat, 100, 75, 400, 155).preserve_aspect_ratio('xMaxYMax', 'slice')
    canvas.rect(100, 75, 400, 155).styles(:fill => 'none', :stroke => 'blue')

    canvas.line(150, 20, 305, 20)
    canvas.line(345, 20, 500, 20)
    canvas.line(150, 250, 305, 250)
    canvas.line(340, 250, 500, 250)
    canvas.g.styles(:stroke=>'none', :font_weight=>'normal', :font_style=>'normal') do |t|
        t.text(310, 23, 'meet')
        t.text(60, 140, 'none')
        t.text(170, 140, 'xMinYMin')
        t.text(300, 140, 'xMidYMid')
        t.text(425, 140, 'xMaxYMax')
        t.text(310, 253, 'slice')
    end

end

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

Version data entries

15 entries across 15 versions & 2 rubygems

Version Path
rmagick-2.13.4 doc/ex/image.rb
rmagick-2.13.3 doc/ex/image.rb
rmagick-2.13.3.rc1 doc/ex/image.rb
rmagick-2.13.2 doc/ex/image.rb
rdp-rmagick-0.0.0 doc/ex/image.rb
rmagick-2.13.1 doc/ex/image.rb
rmagick-2.12.2 doc/ex/image.rb
rmagick-2.12.1 doc/ex/image.rb
rmagick-2.12.0 doc/ex/image.rb
rmagick-2.11.1 doc/ex/image.rb
rmagick-2.10.0 doc/ex/image.rb
rmagick-2.11.0 doc/ex/image.rb
rmagick-2.9.1 doc/ex/image.rb
rmagick-2.9.0 doc/ex/image.rb
rmagick-2.9.2 doc/ex/image.rb