Bézier

A Ruby gem that can draw Bézier curves By Yihang Ho

A few days back, I published a Ruby gem, Bezier. Bezier is a library that can draw Bézier curves and produce PNG (thanks for ChunkyPNG).

Using Bezier is super simple. First, install it:

gem install bezier

then do some magic with your Ruby script:

require 'bezier'

# Create some control points
control_points = [[20, 20], [20, 100], [200, 100], [200, 20]].map do |coord|
  Bezier::Point.new *coord
end

# Create a Bézier curve using those control points
bezier = Bezier::Bezier.new *control_points

# Produce the PNG at Bézier.png
Bezier::Painter.new { |p| p.points = bezier.run }.save

Do try it out!