Skip to main content

tumo_path/build/
mod.rs

1use crate::{Angle, Point, Transform};
2
3mod apply;
4mod canvas;
5mod extend;
6mod geometry;
7mod relative;
8mod svg;
9
10pub use apply::{PathAppliable, PathApply};
11pub use canvas::PathCanvas;
12pub use extend::PathExtend;
13pub use geometry::PathGeometry;
14pub use relative::PathRelative;
15pub use svg::PathSvg;
16
17/// Core trait for building path objects in vector graphics.
18pub trait PathCore {
19	/// Returns the current position in the path.
20	fn current(&self) -> Point;
21
22	/// Moves the current position to the specified point.
23	#[inline(always)]
24	fn move_to(&mut self, to: impl Into<Point>) -> &mut Self {
25		self.move_to_impl(to.into())
26	}
27	fn move_to_impl(&mut self, to: Point) -> &mut Self;
28
29	/// Draws a straight line from the current position to the specified point.
30	#[inline(always)]
31	fn line_to(&mut self, to: impl Into<Point>) -> &mut Self {
32		self.line_to_impl(to.into())
33	}
34	fn line_to_impl(&mut self, to: Point) -> &mut Self;
35
36	/// Draws a quadratic Bézier curve from the current position to the specified point with the given control point.
37	#[inline(always)]
38	fn quadratic_to(&mut self, c1: impl Into<Point>, to: impl Into<Point>) -> &mut Self {
39		self.quadratic_to_impl(c1.into(), to.into())
40	}
41	fn quadratic_to_impl(&mut self, c1: Point, to: Point) -> &mut Self;
42
43	/// Draws a cubic Bézier curve from the current position to the specified point with the given control points.
44	#[inline(always)]
45	fn cubic_to(&mut self, c1: impl Into<Point>, c2: impl Into<Point>, to: impl Into<Point>) -> &mut Self {
46		self.cubic_to_impl(c1.into(), c2.into(), to.into())
47	}
48	fn cubic_to_impl(&mut self, c1: Point, c2: Point, to: Point) -> &mut Self;
49
50	/// Closes the current sub-path by drawing a straight line back to the starting point.
51	fn close(&mut self) -> &mut Self;
52}