Skip to content

Commit

Permalink
Add missing documentation in fj
Browse files Browse the repository at this point in the history
  • Loading branch information
hannobraun committed Mar 29, 2022
1 parent 5b21760 commit 335598f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions fj/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
4 changes: 4 additions & 0 deletions fj/src/shape_2d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ impl Circle {
}
}

/// Access the circle's radius
pub fn radius(&self) -> f64 {
self.radius
}
Expand Down Expand Up @@ -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 }
}
Expand All @@ -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
}
Expand Down
4 changes: 4 additions & 0 deletions fj/src/shape_3d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down

0 comments on commit 335598f

Please sign in to comment.