From 335598fe521f5eece16e9808b690ce0802e60b28 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Tue, 29 Mar 2022 17:56:22 +0200 Subject: [PATCH] Add missing documentation in `fj` --- fj/src/lib.rs | 3 +++ fj/src/shape_2d.rs | 4 ++++ fj/src/shape_3d.rs | 4 ++++ 3 files changed, 11 insertions(+) diff --git a/fj/src/lib.rs b/fj/src/lib.rs index dc93934ba..da2258b36 100644 --- a/fj/src/lib.rs +++ b/fj/src/lib.rs @@ -21,6 +21,9 @@ pub use self::{shape_2d::*, shape_3d::*}; #[derive(Clone, Debug)] #[repr(C)] pub enum Shape { + /// A 2D shape Shape2d(Shape2d), + + /// A 3D shape Shape3d(Shape3d), } diff --git a/fj/src/shape_2d.rs b/fj/src/shape_2d.rs index 61b4de9dd..50aae3b8f 100644 --- a/fj/src/shape_2d.rs +++ b/fj/src/shape_2d.rs @@ -46,6 +46,7 @@ impl Circle { } } + /// Access the circle's radius pub fn radius(&self) -> f64 { self.radius } @@ -91,6 +92,7 @@ pub struct Difference2d { } impl Difference2d { + /// Create a `Difference2d` from two shapes pub fn from_objects(a: Shape2d, b: Shape2d) -> Self { Self { a, b } } @@ -100,10 +102,12 @@ impl Difference2d { self.a.color() } + /// Access the original shape pub fn a(&self) -> &Shape2d { &self.a } + /// Access the shape being subtracted pub fn b(&self) -> &Shape2d { &self.b } diff --git a/fj/src/shape_3d.rs b/fj/src/shape_3d.rs index 0491f2d27..be6ae2ba1 100644 --- a/fj/src/shape_3d.rs +++ b/fj/src/shape_3d.rs @@ -99,18 +99,22 @@ pub struct Sweep { } impl Sweep { + /// Create a `Sweep` from a shape and a length pub fn from_shape_and_length(shape: Shape2d, length: f64) -> Self { Self { shape, length } } + /// Access the shape being swept pub fn shape(&self) -> &Shape2d { &self.shape } + /// Access the length of the sweep pub fn length(&self) -> f64 { self.length } + /// Access the color of the shape being swept pub fn color(&self) -> [u8; 4] { self.shape().color() }