Skip to content

sideshow/clipper2-ruby

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Clipper2 Ruby

A pure Ruby implementation of the Clipper2 polygon clipping and offsetting library.

Acknowledgements

This library is a Ruby port of clipper2-rust, which is itself a Rust port of the original Clipper2 C++ library by Angus Johnson. This project wouldn't be possible without both of these excellent libraries.

License

Licensed under the Boost Software License 1.0, the same license as the original Clipper2 library.

Features

  • Boolean polygon clipping (intersection, union, difference, XOR)
  • Polygon and polyline offsetting with miter, round, and square joins
  • Minkowski sum and difference
  • Rect clipping

Installation

Add to your Gemfile:

gem "clipper2", github: "sideshow/clipper2-ruby"

Usage

require "clipper2"

# Create paths
subject = [
  Clipper2::Point64.new(x: 0, y: 0),
  Clipper2::Point64.new(x: 100, y: 0),
  Clipper2::Point64.new(x: 100, y: 100),
  Clipper2::Point64.new(x: 0, y: 100)
]

# Union operation
result = Clipper2.union_subjects64([subject], Clipper2::FillRule::NON_ZERO)

# Path offsetting (e.g., wall thickness)
inflated = Clipper2.inflate_paths64(
  [path],
  delta: 60,
  join_type: Clipper2::JoinType::MITER,
  end_type: Clipper2::EndType::SQUARE,
  miter_limit: 3.0
)

About

Ruby port of the Clipper2 polygon clipping and offsetting library

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages