Draught - a Geometry library for creating vector graphics

draught, v.

  1. To make a plan or sketch of; esp. to draw a preliminary plan of (something to be constructed); to design. (Sometimes draft.)

Oxford English Dictionary

Draught is a library for creating vector graphics as PDFs. It's grown out of generating shapes that can be laser cut, and that's still its focus.

TODO: Explain the fundamental concepts

Installation

To use it as a library add this line to your application's Gemfile:

gem 'draught'

And then execute:

$ bundle

Or install it yourself as:

$ gem install draught

Usage

Example docs are bad and I will fix them.

Also having to require everything individually.

Create a simple straight line and add it to a sheet, then generate a PDF with it:

require 'draught/line'
require 'draught/bounding_box'
require 'draught/sheet'
require 'draught/renderer'

line = Draught::Line.horizontal(100).translate(Draught::Vector.new(100,100))
box = Draught::BoundingBox.new(line)
sheet = Draught::Sheet.new(width: 300, height: 200, containers: [box])

renderer = Draught::Renderer.render_to_file(sheet, './example.pdf')

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/fidothe/draught. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.