Rclipper is a polygon clipping tool implemented in pure ruby. The algorithm is based on "Efficient clipping of arbitrary polygons by Günther Greiner and Kai Hormann". Degeneracy fix by Erich L Foster and James Overfelt. Also thanks to Helder Correia (https://github.com/helderco/univ-polyclip)
Add this line to your application's Gemfile:
gem 'rclipper'
And then execute:
$ bundle
Or install it yourself as:
$ gem install rclipper
require 'rclipper'
a = [[0,0], [100,0], [100,50], [0,50]]
b = [[0,25], [20,100], [75,25], [100,50], [100,0], [0,50]]
c = Rclipper::clip_polygon(a,b)
- Fork it ( https://github.com/[my-github-username]/rclipper/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request