File: Use02.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 (21 lines) | stat: -rw-r--r-- 781 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
require 'rvg/rvg'

Magick::RVG.dpi = 90

rvg = Magick::RVG.new(10.cm, 3.5.cm).viewbox(0, 0, 100, 35) do |canvas|
    canvas.background_fill = 'white'
    canvas.desc = "Example Use02 - Chain 'styles' to 'use'"
    r = Magick::RVG::Group.new do |grp|
            grp.rect(60, 10).styles(:fill=>'yellow')
        end
    canvas.rect(99.6, 34.6, 0.1, 0.1).styles(:fill=>'none', :stroke=>'blue', :stroke_width=>0.2)

    # Since the rectangle specified the fill color the :fill style is ignored here.
    # However, since the rectangle did not specify a stroke color, the :stroke style
    # specified here is respected.
    canvas.use(r, 20, 5).styles(:fill=>'green', :stroke=>'red')
    canvas.use(r, 20, 20).styles(:fill=>'green', :stroke=>'blue')
end

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