Sha256: 197ac8460e69ccd05350c6504a6cbbfbd345968a74200549e5d408df4a1e6bc2

Contents?: true

Size: 951 Bytes

Versions: 6

Compression:

Stored size: 951 Bytes

Contents

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

imgl = Magick::ImageList.new
imgl.new_image(540, 200, Magick::HatchFill.new('white', 'lightcyan2'))
gc = Magick::Draw.new

# Draw Bezier curve
gc.stroke('red')
gc.stroke_width(3)
gc.fill_opacity(0)
gc.bezier(100, 150, 25, 50, 475, 50, 400, 150)

# Draw circles around endpoints
gc.fill_opacity(0)
gc.stroke('gray50').stroke_width(1)
gc.circle(100, 150, 103, 153)
gc.circle(400, 150, 403, 153)
gc.line(100, 150, 25, 50)
gc.line(400, 150, 475, 50)

# Draw filled circles around control points
gc.fill_opacity(1)
gc.fill('gray50')
gc.circle(25, 50, 28, 53)
gc.circle(475, 50, 478, 53)

# Annotate
gc.font_weight(Magick::NormalWeight)
gc.font_style(Magick::NormalStyle)
gc.fill('black')
gc.stroke('transparent')
gc.text(107, 150, "'100,150'")
gc.text(30, 50, "'25,50'")
gc.text(409, 150, "'400,150'")
gc.text(480, 50, "'475,50'")

gc.draw(imgl)
imgl.border!(1, 1, 'lightcyan2')
imgl.write('cbezier3.gif')
exit(0)

Version data entries

6 entries across 6 versions & 1 rubygems

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