From 785d9c8798430272218aec3b16b8244f8d2dbe81 Mon Sep 17 00:00:00 2001 From: rmagick Date: Wed, 20 Apr 2005 23:13:30 +0000 Subject: [PATCH] New --- doc/ex/baseline_shift01.rb | 19 +++++++++++++++++++ doc/ex/text_styles.rb | 22 ++++++++++++++++++++++ doc/ex/writing_mode01.rb | 28 ++++++++++++++++++++++++++++ doc/ex/writing_mode02.rb | 27 +++++++++++++++++++++++++++ 4 files changed, 96 insertions(+) create mode 100644 doc/ex/baseline_shift01.rb create mode 100644 doc/ex/text_styles.rb create mode 100644 doc/ex/writing_mode01.rb create mode 100644 doc/ex/writing_mode02.rb diff --git a/doc/ex/baseline_shift01.rb b/doc/ex/baseline_shift01.rb new file mode 100644 index 000000000..e32132985 --- /dev/null +++ b/doc/ex/baseline_shift01.rb @@ -0,0 +1,19 @@ +require 'rvg/rvg' +include Magick + +rvg = 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') + diff --git a/doc/ex/text_styles.rb b/doc/ex/text_styles.rb new file mode 100644 index 000000000..2ceba0050 --- /dev/null +++ b/doc/ex/text_styles.rb @@ -0,0 +1,22 @@ +#! /usr/local/bin/ruby -w +require 'rvg/rvg' +include Magick + + +rvg = RVG.new(200, 100) do |canvas| + canvas.background_fill = 'white' + + canvas.g.styles(:font_size=>16) 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') + diff --git a/doc/ex/writing_mode01.rb b/doc/ex/writing_mode01.rb new file mode 100644 index 000000000..096c8d3a4 --- /dev/null +++ b/doc/ex/writing_mode01.rb @@ -0,0 +1,28 @@ +require 'rvg/rvg' +include Magick + +RVG.dpi = 90 + +TEXT_STYLES = {:writing_mode=>'tb', + :glyph_orientation_vertical=>0, + :fill=>'red4', + :font_weight=>'bold', + :font_size=>16} + +TEXT_STYLES2 = {:writing_mode=>'tb', + :glyph_orientation_vertical=>90, + :fill=>'green', + :font_weight=>'bold', + :font_size=>16} + +rvg = RVG.new(1.25.in, 6.in).viewbox(0,0,125,600) do |canvas| + canvas.background_fill = 'white' + + canvas.text(40, 15, ":glyph_orientation_vertical=0").styles(TEXT_STYLES) + canvas.text(80, 25, ":glyph_orientation_vertical=90").styles(TEXT_STYLES2) + + canvas.rect(124, 598).styles(:fill=>'none',:stroke=>'blue') +end + +rvg.draw.write('writing_mode01.gif') + diff --git a/doc/ex/writing_mode02.rb b/doc/ex/writing_mode02.rb new file mode 100644 index 000000000..8f0de8903 --- /dev/null +++ b/doc/ex/writing_mode02.rb @@ -0,0 +1,27 @@ +require 'rvg/rvg' +include Magick + +RVG.dpi = 90 + +TEXT_STYLES = {:writing_mode=>'lr', + :glyph_orientation_horizontal=>0, + :fill=>'red4', + :font_weight=>'bold', + :font_size=>16} + +TEXT_STYLES2 = {:writing_mode=>'lr', + :glyph_orientation_horizontal=>180, + :fill=>'green', + :font_weight=>'bold', + :font_size=>16} + +rvg = RVG.new(3.in, 1.in).viewbox(0,0,300,100) do |canvas| + canvas.background_fill = 'white' + + canvas.text(15, 40, ":glyph_orientation_horizontal=0").styles(TEXT_STYLES) + canvas.text(15, 80, ":glyph_orientation_horizontal=180").styles(TEXT_STYLES2) + + canvas.rect(299, 99).styles(:fill=>'none',:stroke=>'blue') +end + +rvg.draw.write('writing_mode02.gif')