File: text_styles.rb

package info (click to toggle)
ruby-rmagick 6.0.1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 8,232 kB
  • sloc: cpp: 19,563; ruby: 17,147; sh: 88; javascript: 36; makefile: 13
file content (18 lines) | stat: -rw-r--r-- 663 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
require 'rvg/rvg'

rvg = Magick::RVG.new(200, 100) do |canvas|
  canvas.background_fill = 'white'

  canvas.g.styles(font_size: 16, font_weight: 'normal', font_style: 'normal') do |grp|
    grp.text(30, 30, ":text_anchor=>'start'").styles(text_anchor: 'start')
    grp.circle(1, 30, 30).styles(stroke: 'red')
    grp.text(100, 50, ":text_anchor=>'middle'").styles(text_anchor: 'middle')
    grp.circle(1, 100, 50).styles(stroke: 'red')
    grp.text(170, 70, ":text_anchor=>'end'").styles(text_anchor: 'end')
    grp.circle(1, 170, 70).styles(stroke: 'red')
  end

  canvas.rect(199, 99).styles(fill: 'none', stroke: 'blue')
end

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