diff --git a/components/style/bezier.rs b/components/style/bezier.rs index ba3d33a2394..0d74bf5da42 100644 --- a/components/style/bezier.rs +++ b/components/style/bezier.rs @@ -6,10 +6,13 @@ //! //! This is based on `WebCore/platform/graphics/UnitBezier.h` in WebKit. +#![deny(missing_docs)] + use euclid::point::Point2D; const NEWTON_METHOD_ITERATIONS: u8 = 8; +/// A Bézier curve. pub struct Bezier { ax: f64, bx: f64, @@ -20,6 +23,7 @@ pub struct Bezier { } impl Bezier { + /// Create a Bézier curve from two control points. #[inline] pub fn new(p1: Point2D, p2: Point2D) -> Bezier { let cx = 3.0 * p1.x; @@ -96,6 +100,8 @@ impl Bezier { t } + /// Solve the bezier curve for a given `x` and an `epsilon`, that should be + /// between zero and one. #[inline] pub fn solve(&self, x: f64, epsilon: f64) -> f64 { self.sample_curve_y(self.solve_curve_x(x, epsilon))