File: baseline_shift01.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 (17 lines) | stat: -rw-r--r-- 579 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
require 'rvg/rvg'

rvg = Magick::RVG.new(150, 100) do |canvas|
  canvas.background_fill = 'white'
  canvas.text(40, 35).styles(font_weight: 'bold', font_size: 28) do |txt|
    txt.tspan('H')
    txt.tspan('2').styles(font_size: 20, fill: 'red', baseline_shift: 'sub')
    txt.tspan('O')
  end
  canvas.text(40, 80).styles(font_style: 'italic', font_size: 28) do |txt|
    txt.tspan('e=mc')
    txt.tspan('2').styles(font_size: 20, fill: 'red', baseline_shift: 'super')
  end
  canvas.rect(149, 99).styles(fill: 'none', stroke: 'blue')
end

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