From c82fcac77f5cd8fbf6c7efc387e5c4c48ce1d7ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Sat, 31 Dec 2016 14:03:49 +0100 Subject: [PATCH] style: Document the bezier module. --- components/style/bezier.rs | 6 ++++++ 1 file changed, 6 insertions(+) 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))