fschutt / printpdf

A fully-featured PDF library for Rust, WASM-ready
https://fschutt.github.io/printpdf/
MIT License
829 stars 98 forks source link

Implement adding a rectangle to a pdf layer #163

Closed dodomorandi closed 10 months ago

dodomorandi commented 11 months ago

This should improve the support to writing PDFs towards two directions:

  1. The ability of stroke/fill rectangles
  2. The possibility of using simple clipping operations based on rectangles

The changes should be pretty straightforward, and I also added a few changes/fixes to the doc. Still, there are a couple of points I would like to discuss:

Let me know what do you think, and feel free to give any suggestion I could improve the code or the doc.

Last but not least: this is a breaking change because of the new Rect::mode field (and cargo-semver-checks confirms that).

CC @paolobarbolini

dodomorandi commented 11 months ago

I moved WindingOrder and PolygonMode to a path module, and I also renamed PolygonMode to PaintMode. Because of this change I also took the opportunity of add some docs and some minor changes.

Just keep in mind that at this point we still miss the possibility of choosing between open and closed paint operations in polygons, but it probably makes sense to have a flag specifically in the Polygon struct (because it does not make sense for rectangles and circles) and therefore it should be handled in another PR.

Let me know if it's ok for you or you would rather to change things a bit or to split this PR in two (because of the refactor).