Skip to content

Creates a Bézier curve by its control points. Implemented with de Casteljau method.

Notifications You must be signed in to change notification settings

ivan05almeida/beziercurve

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 

Repository files navigation

Bézier Ruby Gem

A Ruby gem for creating and analyzing Bézier curves. Allows you to create a Bézier curve by its control points, get specific point on that curve or iterate the curve points by an Enumerator. Inspired by A Primer on Bézier Curves.

History

0.7 - implemented the De Casteljau algorithm

0.8 - defined minimum Ruby version (2.0.0)

Installation

> gem install beziercurve

Sample

> require 'beziercurve'
> bez = Bezier::Curve.new(Bezier::ControlPoint.new(40, 250), Bezier::ControlPoint.new(50, 150), Bezier::ControlPoint.new(90, 220))
> puts bez.point_on_curve(0.2).x;
45.2
> puts bez.point_on_curve(0.2).y;
216.8

or a nicer way:

> bez = Bezier::Curve.new([40, 250], [50, 150], [90, 220])
> puts bez.point_on_curve(0.2).x;
45.2
> puts bez.point_on_curve(0.2).y;
216.8

About

Creates a Bézier curve by its control points. Implemented with de Casteljau method.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 100.0%