Sha256: b2568dd611cb4ebce68be6cc71c0dfddacb51423af5e5e13d21bcd7ffe767995

Contents?: true

Size: 1.19 KB

Versions: 44

Compression:

Stored size: 1.19 KB

Contents

require 'rvg/rvg'

def example(cols, rows)
    rvg = Magick::RVG.new(cols, rows) do |canvas|
        canvas.background_fill = 'white'
        canvas.desc = <<-'END_DESC'
            Example ViewBox - uses the viewBox attribute to automatically create an
            initial user coordinate system which causes the graphic to scale to fit
            into the viewport no matter what size the viewport is.
            END_DESC

        canvas.viewbox(0, 0, 1500, 1000)
        canvas.preserve_aspect_ratio('none')

        # This rectangle goes from (0,0) to (1500,1000) in user space.
        # Because of the viewBox attribute above,
        # the rectangle will end up filling the entire area
        # reserved for the SVG content.
        canvas.rect(1500, 1000).styles(:fill=>'yellow',:stroke=>'blue',:stroke_width=>12)

        # A large, red triangle
        canvas.path("M 750,100 L 250,900 L 1250,900 z").styles(:fill=>'red')

        # A text string that spans most of the viewport
        canvas.text(100, 600, 'Stretch to fit').styles(:font_size=>200, :font_family=>'Verdana')

    end
    return rvg.draw
end

example(300, 200).write('ViewBox_300x200.gif')
example(150, 200).write('ViewBox_150x200.gif')

Version data entries

44 entries across 44 versions & 1 rubygems

Version Path
rmagick-1.10.1 doc/ex/ViewBox.rb
rmagick-1.10.0 doc/ex/ViewBox.rb
rmagick-1.11.1 doc/ex/ViewBox.rb
rmagick-1.11.0 doc/ex/ViewBox.rb
rmagick-1.13.0 doc/ex/ViewBox.rb
rmagick-1.12.0 doc/ex/ViewBox.rb
rmagick-1.15.10 doc/ex/ViewBox.rb
rmagick-1.14.1 doc/ex/ViewBox.rb
rmagick-1.14.0 doc/ex/ViewBox.rb
rmagick-1.15.0 doc/ex/ViewBox.rb
rmagick-1.15.1 doc/ex/ViewBox.rb
rmagick-1.15.12 doc/ex/ViewBox.rb
rmagick-1.15.11 doc/ex/ViewBox.rb
rmagick-1.15.15 doc/ex/ViewBox.rb
rmagick-1.15.13 doc/ex/ViewBox.rb
rmagick-1.15.14 doc/ex/ViewBox.rb
rmagick-1.15.17 doc/ex/ViewBox.rb
rmagick-1.15.16 doc/ex/ViewBox.rb
rmagick-1.15.2 doc/ex/ViewBox.rb
rmagick-1.15.3 doc/ex/ViewBox.rb