Sha256: 01bcb98b20f5c7dc4143f2365feca6b6dade89ec9fe08a89e3cbdd3269de0521

Contents?: true

Size: 1.11 KB

Versions: 6

Compression:

Stored size: 1.11 KB

Contents

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

i = Magick::Image.new(300, 220, Magick::HatchFill.new('white', 'lightcyan2'))
gc = Magick::Draw.new

# Draw the border rectangle.
gc.fill_opacity(0)
gc.stroke_width(1)
gc.stroke('gray50')
gc.rectangle(40, 50, 250, 180)

# Draw the circles around the rectangle corners and
# arc endpoints. All the circles have a 3-pixel radius.
gc.circle(40, 50, 40 + 3, 50)
gc.circle(250, 180, 250 + 3, 180)
gc.circle(250, 114, 250 + 3, 114)
gc.circle(146, 50, 146 + 3, 50)

# Annotate
gc.font_weight(Magick::NormalWeight)
gc.font_style(Magick::NormalStyle)
gc.stroke('transparent')
gc.fill('black')
gc.fill_opacity(1)

# xMagick recognizes the braces as delimiters.
gc.gravity(Magick::NorthWestGravity)
gc.text(42, 37, '{40, 50}')
gc.text(188, 108, '{0 degrees}')

gc.gravity(Magick::SouthEastGravity)
gc.text(300 - 250, 220 - 195, '{250, 180}')

gc.gravity(Magick::NorthGravity)
gc.text(0, 67, '{270 degrees}')

# Draw the arc
gc.fill_opacity(0)
gc.stroke('red').stroke_width(3)
gc.arc(40, 50, 250, 180, 0, 270)

# Draw on the canvas
gc.draw(i)

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

# i.display
i.write('arc.gif')

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rmagick-4.1.0.rc2 doc/ex/arc.rb
rmagick-4.1.0.rc1 doc/ex/arc.rb
rmagick-4.0.0 doc/ex/arc.rb
rmagick-3.2.0 doc/ex/arc.rb
rmagick-3.1.0 doc/ex/arc.rb
rmagick-3.0.0 doc/ex/arc.rb