1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
#![doc(html_logo_url = "https://nical.github.io/lyon-doc/lyon-logo.svg")] //! # Lyon path builder //! //! Tools to build path objects from a sequence of imperative commands. //! //! ## Examples //! //! The following example shows the Builder struct from the //! [lyon_path](https://docs.rs/lyon_path/*/lyon_path) crate using the //! [BaseBuilder](traits.BaseBuilder.html) interface. //! //! ```ignore //! use lyon_path::Path; //! use lyon_core::math::{point}; //! use lyon_path_builder::*; //! //! // Create a builder object to build the path. //! let mut builder = Path::builder(); //! //! // Build a simple path using the BaseBuilder interface. //! builder.move_to(point(0.0, 0.0)); //! builder.line_to(point(1.0, 2.0)); //! builder.line_to(point(2.0, 0.0)); //! builder.line_to(point(1.0, 1.0)); //! builder.close(); //! //! // Finish building and create the actual path object. //! let path = builder.build(); //! ``` //! //! The next example uses the [PathBuilder](traits.PathBuilder.html) trait, which adds //! some simple curves to the [BaseBuilder](traits.BaseBuilder.html) trait. //! //! ```ignore //! let mut builder = Path::builder(); //! //! builder.move_to(point(0.0, 0.0)); //! builder.line_to(point(1.0, 0.0)); //! builder.quadratic_bezier_to(point(2.0, 0.0), point(2.0, 1.0)); //! builder.cubic_bezier_to(point(2.0, 2.0), point(0.0, 2.0), point(0.0, 0.0)); //! builder.close(); //! //! let path = builder.build(); //! ``` //! //! The [SvgBuilder](trait.SvgBuilder.html) Adds to [PathBuilder](traits.PathBuilder.html) //! the rest of the [SVG path](https://svgwg.org/specs/paths/) commands. //! //! These SVG commands can approximated with the simpler set of commands supported by //! [PathBuilder](traits.PathBuilder.html). Therefore it is possible to create an SvgBuilder //! adapter on top of a PathBuilder using the with_svg method: //! //! ```ignore //! let mut builder = Path::builder().with_svg(); //! //! builder.move_to(point(0.0, 0.0)); //! builder.horizontal_line_to(1.0); //! builder.relative_quadratic_bezier_to(point(1.0, 0.0), point(1.0, 1.0)); //! builder.smooth_relative_quadratic_bezier_to(point(-1.0, 1.0)); //! //! let path = builder.build(); //! ``` //! //! To build a path that approximates curves with a sequence of line segments, use the //! flattened method: //! //! ```ignore //! let tolerance = 0.05;// maximum distance between a curve and its approximation. //! let mut builder = Path::builder().flattened(tolerance); //! //! builder.move_to(point(0.0, 0.0)); //! builder.quadratic_bezier_to(point(1.0, 0.0), point(1.0, 1.0)); //! builder.close(); //! //! // The resulting path contains only MoveTo, LineTo and Close events. //! let path = builder.build(); //! ``` //! extern crate lyon_core as core; extern crate lyon_bezier as bezier; mod path_builder; mod arc; #[doc(inline)] pub use path_builder::*; pub use core::*;