Sha256: 77d33719770634e454505d0761567dcbbe9e82703436586b354119b2362df7c1

Contents?: true

Size: 830 Bytes

Versions: 13

Compression:

Stored size: 830 Bytes

Contents

#!/usr/bin/env ruby -w
require 'rmagick'

imgl = Magick::ImageList.new
imgl.new_image(250, 250, Magick::HatchFill.new('white','lightcyan2'))

gc = Magick::Draw.new
gc.stroke('red')
gc.stroke_width(2)

# Move the origin to the center.
gc.translate(125, 125)
max_x = imgl.columns/2
max_y = imgl.rows/2

# Draw down-pointing arrow
gc.line(0, -max_y,   0, max_y)
gc.line(0,  max_y,  10, max_y-10)
gc.line(0,  max_y, -10, max_y-10)

# Draw right-pointing arrow
gc.line(-max_x, 0, max_x,     0)
gc.line( max_x, 0, max_x-10, -10)
gc.line( max_x, 0, max_x-10,  10)

# Add labels
gc.font_weight(Magick::NormalWeight)
gc.font_style(Magick::NormalStyle)
gc.fill('black')
gc.stroke('transparent')
gc.text(8, 15, "'0,0'")
gc.text(105, 16, 'x')
gc.text(12, 115, 'y')

gc.draw(imgl)

imgl.border!(1,1, 'lightcyan2')

imgl.write('translate.gif')

Version data entries

13 entries across 13 versions & 3 rubygems

Version Path
rmagick-windows-2.16.5 doc/ex/translate.rb
rmagick-windows-2.16.4 doc/ex/translate.rb
rmagick-windows-2.16.3 doc/ex/translate.rb
rmagick-windows-2.16.2 doc/ex/translate.rb
rmagick-windows-2.16.1 doc/ex/translate.rb
mdg-1.0.1 vendor/bundle/ruby/2.3.0/gems/rmagick-2.16.0/doc/ex/translate.rb
rmagick-2.16.0 doc/ex/translate.rb
rmagick-2.15.4 doc/ex/translate.rb
rmagick-2.15.3 doc/ex/translate.rb
rmagick-2.15.2 doc/ex/translate.rb
rmagick-2.15.1 doc/ex/translate.rb
rmagick-2.15.0 doc/ex/translate.rb
rmagick-2.14.0 doc/ex/translate.rb