aoer_plotty_rs/
lib.rs

1//! # AOER-PLOTTY-RS : ArmyOfEvilRobots pen-plotter art related tools and libraries
2//!
3//! [![Package][package-img]][package-url] [![Documentation][documentation-img]][documentation-url]
4//!
5//! This library contains a variety of tools used to make pen-plotter based art.
6//! While it focuses on a combination of nannou and geo/geo_types for now, it
7//! will likely expand into other areas as I find the need for my own creations.
8//! Based (extremely roughly) on [`shapely`] for Python for the geographic
9//! functions, with a splash of [`VSK`].
10//!
11//! *CAUTION: This isn't even Alpha quality yet, and I am poking away at it on
12//! my days off. May spontaneously explode, might take your plotter with it.*
13//!
14//! [`shapely`]: https://github.com/shapely/shapely
15//! [`vsk`]: https://vsketch.readthedocs.io/en/latest/index.html
16//!
17//! # Changelog
18//! * 0.2.2. Bugfixens! The regular_poly_native function was duplicating
19//!          points, resulting in invalid geometries.
20//! * 0.2.1. Optimizations and plotters:
21//!   * Add optimization to toolpaths/line-ordering so that we don't waste
22//!     valuable time traversing empty space when plotting.
23//!   * Add simple serial-plotter support
24//! * 0.2.0. We made it!!!!
25//!   * Typography module. It's buggy and ugly, but we can now place simple
26//!     text on the sketches.
27//!   * Performance improvements; particularly on complex overlapping
28//!     geometries
29//!   * Truchet tiles (Carlson Smith)
30//!   * Example of using a UI in Nannou to customize a sketch
31//! * 0.1.11. Added the first "element" (reusable sketch component) in the form
32//!          of the [`elements::CarlsonSmithTruchet`], which provides tileable
33//!          and scalable truchets which make for some very interesting patterns.
34//!          Think of them as the "goto 10" tiles on steroids.
35//!          Also added a to_geos trait which makes it easy to convert
36//!          back and forth from geo_types without fancy and unpredictable
37//!          From/Into magic.
38//!          Also added a [`geo_types::shapes`] module which provides some
39//!          additional primitives (arc, polygons, circles).
40//!          Added the [`geo_types::boolean::BooleanOp`] trait to allow for
41//!          boolean operations directly against geo_types.
42//! * 0.1.10. Getting close to having to do a 0.2 release. Added the 'flatten'
43//!          method to [`context::Context`] so that you can merge all your
44//!          pen strokes that live on the same layer. Good for merging
45//!          overlapping polygons. Layer is defined as "exact same color, pen,
46//!          and fill configuration"
47//! * 0.1.9. Add masking to context: You can now mask the drawable area with
48//!          any [`geo_types::Geometry`] variant and only areas under the mask
49//!          will actually render. Also changed some performance and accuracy
50//!          related optimizations so that clipped items look clean.
51//!          Also added the final Generative Artistry examples. I'll miss
52//!          implementing those :(
53//! * 0.1.8. Add a bunch of new features to Context, including regular polygons
54//!          and tesselated polys (stars of various point counts). Circles are
55//!          now somewhat simpler as well.
56//! * 0.1.7. Another big change. Added the Context drawing library, which is HUGE,
57//!   and contains way too much functionality to discuss here.
58//! * 0.1.6. Various changes:
59//!   * Add [`geo_types::buffer::Buffer`] trait to offset polygons
60//!   * Add [`geo_types::clip::LineClip`] trait to Clip geometry with
61//!     OTHER geometry.
62//!   * [`geo_types::svg::Arrangement`] trait has been extended to
63//!     better support arbitrary transformations.
64//!   * [`geo_types::svg::Arrangement`] trait has also added a margin
65//!     option to fit geometry on a page with predefined margins.
66//!   * [`geo_types::hatch::OutlineStroke`] is a utility Trait which
67//!     takes a LineString/MultiLineString and applies a stroke, returning
68//!     a MultiLineString containing lines which outline the stroked line
69//!   * [`geo_types::hatch::OutlineFillStroke`] is the same as [`geo_types::hatch::OutlineStroke`]
70//!     except it also fills the stroke with the given HatchPattern. Great for turning
71//!     drawings made of thick lines into nicely filled polygons.
72//!   * Tons more examples which are oxidized versions of the
73//!     [`Generative Artistry tutorials`]
74//! * 0.1.5. Add SVG generation features.
75//! * 0.1.4. Add the [`geo_types::hatch::Hatch`]ing submodule.
76//! * 0.1.3. Breaking change to GCode POST again; use an enum to define the
77//!          the input geometry so that we can add new geometry source types,
78//!          like svg2polyline polylines, or even multilayer geo with tool changes.
79//! * 0.1.2. Mostly documentation improvements. Made MIT license explicit.
80//! * 0.1.1. Breaking change to the GCode POST function to use geo_types in
81//!          order to be consistent with everywhere else in the library.
82//!          Also changed the Turtle/TurtleTrait to just be mutable.
83//! * 0.1.0. Initial commit
84//!
85//! [documentation-img]: https://docs.rs/aoer-plotty-rs/badge.svg
86//! [documentation-url]: https://docs.rs/aoer-plotty-rs
87//! [package-img]: https://img.shields.io/crates/v/aoer-plotty-rs.svg
88//! [package-url]: https://crates.io/crates/aoer-plotty-rs
89//! [`Generative Artistry tutorials`]: https://generativeartistry.com/tutorials/
90
91/// Extensions/Traits for geo_types geometry. Also includes some helper functions
92/// for working with Nannou and geo_types.
93pub mod geo_types;
94
95/// Turtle graphics implementation, including integration with L-systems
96pub mod turtle;
97
98/// L-system implementation, with expansion/recursion
99pub mod l_system;
100
101/// gcode module provides a simple post-processor for line-based art to be converted
102/// into GCode
103pub mod gcode;
104
105/// A stateful drawing context which gives you canvas-ish drawing capabilities
106pub mod context;
107
108/// Errors
109pub mod errors;
110
111/// Elements : Reusable art components, usually designed for use with Context
112pub mod elements;
113
114/// Workbench : Tooling to turn your 'sketches' into interactive UI based tools
115/// that can be used to tweak a design and generate SVG output (and eventually
116/// even to directly plot the result).
117/// Note; this has been prototyped out, but I am not happy with how the process
118/// works yet, so no library here (for now).
119
120/// optimizer
121/// Library that optimizes path to reduce travel time
122pub mod optimizer;
123
124/// Plotter
125/// Module for talking to a serial plotter via gcode
126pub mod plotter;
127
128/// Make your life easy! Just import prelude::* and ignore all the warnings!
129/// One stop shopping at the expense of a slightly more complex dependency graph.
130pub mod prelude {
131    pub use crate::geo_types::hatch::*;
132    pub use crate::geo_types::nannou::NannouDrawer;
133    pub use crate::geo_types::svg::*;
134    pub use crate::geo_types::PointDistance;
135    pub use crate::l_system::LSystem;
136    pub use crate::turtle::{Turtle, TurtleTrait};
137}