Skip to content

Commit

Permalink
Move the primitive module out of the properties mod into draw
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchmindtree committed Aug 3, 2019
1 parent 078c276 commit 10310bd
Show file tree
Hide file tree
Showing 12 changed files with 38 additions and 34 deletions.
10 changes: 4 additions & 6 deletions src/draw/drawing.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use crate::color::IntoLinSrgba;
use crate::draw::primitive::Primitive;
use crate::draw::properties::spatial::{dimension, orientation, position};
use crate::draw::properties::{
ColorScalar, IntoDrawn, Primitive, SetColor, SetDimensions, SetOrientation, SetPosition,
ColorScalar, IntoDrawn, SetColor, SetDimensions, SetOrientation, SetPosition,
};
use crate::draw::{self, Draw};
use crate::geom::graph::node;
Expand Down Expand Up @@ -110,7 +111,7 @@ where
// The functionn is only applied if the node has not yet been **Drawn**.
fn map_primitive<F, T2>(mut self, map: F) -> Drawing<'a, T2, S>
where
F: FnOnce(draw::properties::Primitive<S>) -> draw::properties::Primitive<S>,
F: FnOnce(Primitive<S>) -> Primitive<S>,
T2: IntoDrawn<S> + Into<Primitive<S>>,
{
if let Ok(mut state) = self.draw.state.try_borrow_mut() {
Expand All @@ -134,10 +135,7 @@ where
// vertices.
fn map_primitive_with_vertices<F, T2>(mut self, map: F) -> Drawing<'a, T2, S>
where
F: FnOnce(
draw::properties::Primitive<S>,
&mut draw::IntermediaryMesh<S>,
) -> draw::properties::Primitive<S>,
F: FnOnce(Primitive<S>, &mut draw::IntermediaryMesh<S>) -> Primitive<S>,
T2: IntoDrawn<S> + Into<Primitive<S>>,
{
if let Ok(mut state) = self.draw.state.try_borrow_mut() {
Expand Down
22 changes: 12 additions & 10 deletions src/draw/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,17 @@ pub use self::mesh::intermediary::{
IntermediaryMesh, IntermediaryMeshBuilder, IntermediaryVertexData, IntermediaryVertexDataRanges,
};
pub use self::mesh::Mesh;
use self::primitive::Primitive;
use self::properties::spatial::orientation::{self, Orientation};
use self::properties::spatial::position::{self, Position};
use self::properties::{IntoDrawn, Primitive};
use self::properties::IntoDrawn;
pub use self::theme::Theme;

pub mod backend;
pub mod background;
mod drawing;
pub mod mesh;
pub mod primitive;
pub mod properties;
pub mod theme;

Expand Down Expand Up @@ -84,7 +86,7 @@ where
/// The map from node indices to their vertex and index ranges within the mesh.
ranges: HashMap<node::Index, Ranges>,
/// Primitives that are in the process of being drawn.
drawing: HashMap<node::Index, properties::Primitive<S>>,
drawing: HashMap<node::Index, Primitive<S>>,
/// The last node that was **Drawn**.
last_node_drawn: Option<node::Index>,
/// The theme containing default values.
Expand Down Expand Up @@ -552,42 +554,42 @@ where
}

/// Begin drawing an **Ellipse**.
pub fn ellipse(&self) -> Drawing<properties::Ellipse<S>, S> {
pub fn ellipse(&self) -> Drawing<primitive::Ellipse<S>, S> {
self.a(Default::default())
}

/// Begin drawing a **Line**.
pub fn line(&self) -> Drawing<properties::Line<S>, S> {
pub fn line(&self) -> Drawing<primitive::Line<S>, S> {
self.a(Default::default())
}

/// Begin drawing a **Quad**.
pub fn quad(&self) -> Drawing<properties::Quad<S>, S> {
pub fn quad(&self) -> Drawing<primitive::Quad<S>, S> {
self.a(Default::default())
}

/// Begin drawing a **Rect**.
pub fn rect(&self) -> Drawing<properties::Rect<S>, S> {
pub fn rect(&self) -> Drawing<primitive::Rect<S>, S> {
self.a(Default::default())
}

/// Begin drawing a **Triangle**.
pub fn tri(&self) -> Drawing<properties::Tri<S>, S> {
pub fn tri(&self) -> Drawing<primitive::Tri<S>, S> {
self.a(Default::default())
}

/// Begin drawing a **Polygon**.
pub fn polygon(&self) -> Drawing<properties::primitive::polygon::Pointless, S> {
pub fn polygon(&self) -> Drawing<primitive::polygon::Pointless, S> {
self.a(Default::default())
}

/// Begin drawing a **Mesh**.
pub fn mesh(&self) -> Drawing<properties::primitive::mesh::Vertexless, S> {
pub fn mesh(&self) -> Drawing<primitive::mesh::Vertexless, S> {
self.a(Default::default())
}

/// Begin drawing a **Polyline**.
pub fn polyline(&self) -> Drawing<properties::primitive::PolylineVertexless, S> {
pub fn polyline(&self) -> Drawing<primitive::PolylineVertexless, S> {
self.a(Default::default())
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::draw::primitive::Primitive;
use crate::draw::properties::spatial::{dimension, orientation, position};
use crate::draw::properties::{
spatial, ColorScalar, Draw, Drawn, IntoDrawn, LinSrgba, Primitive, SetColor, SetDimensions,
spatial, ColorScalar, Draw, Drawn, IntoDrawn, LinSrgba, SetColor, SetDimensions,
SetOrientation, SetPosition,
};
use crate::draw::{self, Drawing};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::draw::primitive::Primitive;
use crate::draw::properties::spatial::{orientation, position};
use crate::draw::properties::{
spatial, ColorScalar, Draw, Drawn, IntoDrawn, LinSrgba, Primitive, SetColor, SetOrientation,
SetPosition,
spatial, ColorScalar, Draw, Drawn, IntoDrawn, LinSrgba, SetColor, SetOrientation, SetPosition,
};
use crate::draw::{self, Drawing};
use crate::geom::{self, Point2};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::draw::mesh::vertex::IntoVertex;
use crate::draw::primitive::Primitive;
use crate::draw::properties::spatial::{self, orientation, position};
use crate::draw::properties::{Draw, Drawn, IntoDrawn, Primitive, SetOrientation, SetPosition};
use crate::draw::properties::{Draw, Drawn, IntoDrawn, SetOrientation, SetPosition};
use crate::draw::{self, Drawing};
use crate::geom;
use crate::math::BaseFloat;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use crate::geom;

pub mod ellipse;
pub mod line;
pub mod mesh;
Expand All @@ -9,6 +7,8 @@ pub mod quad;
pub mod rect;
pub mod tri;

use crate::geom;

pub use self::ellipse::Ellipse;
pub use self::line::Line;
pub use self::mesh::Mesh;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::draw::primitive::Primitive;
use crate::draw::properties::spatial::{self, orientation, position};
use crate::draw::properties::{
ColorScalar, Draw, Drawn, IntoDrawn, LinSrgba, Primitive, SetColor, SetOrientation, SetPosition,
ColorScalar, Draw, Drawn, IntoDrawn, LinSrgba, SetColor, SetOrientation, SetPosition,
};
use crate::draw::{self, mesh, Drawing};
use crate::geom;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use crate::color::conv::IntoLinSrgba;
use crate::draw::mesh::vertex::IntoVertex;
use crate::draw::primitive::Primitive;
use crate::draw::properties::spatial::{self, orientation, position};
use crate::draw::properties::{Draw, Drawn, IntoDrawn, Primitive, SetOrientation, SetPosition};
use crate::draw::properties::{Draw, Drawn, IntoDrawn, SetOrientation, SetPosition};
use crate::draw::{self, Drawing};
use crate::geom::{self, pt2};
use crate::math::BaseFloat;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use crate::draw::mesh::vertex::IntoPoint;
use crate::draw::primitive::Primitive;
use crate::draw::properties::spatial::{dimension, orientation, position};
use crate::draw::properties::{
spatial, ColorScalar, Draw, Drawn, IntoDrawn, LinSrgba, Primitive, SetColor, SetDimensions,
spatial, ColorScalar, Draw, Drawn, IntoDrawn, LinSrgba, SetColor, SetDimensions,
SetOrientation, SetPosition,
};
use crate::draw::{self, Drawing};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use crate::draw;
use crate::draw::primitive::Primitive;
use crate::draw::properties::spatial::{dimension, orientation, position};
use crate::draw::properties::{
spatial, ColorScalar, Draw, Drawn, IntoDrawn, LinSrgba, Primitive, SetColor, SetDimensions,
spatial, ColorScalar, Draw, Drawn, IntoDrawn, LinSrgba, SetColor, SetDimensions,
SetOrientation, SetPosition,
};
use crate::geom::{self, Point2, Vector2};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use crate::draw::mesh::vertex::IntoPoint;
use crate::draw::primitive::Primitive;
use crate::draw::properties::spatial::{dimension, orientation, position};
use crate::draw::properties::{
spatial, ColorScalar, Draw, Drawn, IntoDrawn, LinSrgba, Primitive, SetColor, SetDimensions,
spatial, ColorScalar, Draw, Drawn, IntoDrawn, LinSrgba, SetColor, SetDimensions,
SetOrientation, SetPosition,
};
use crate::draw::{self, Drawing};
Expand Down
11 changes: 4 additions & 7 deletions src/draw/properties/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,18 @@
//! Each **Drawing** instance is associated with a specific **Node** in the geometry graph and has
//! a unique **node::Index** to simplify this.

pub mod color;
pub mod spatial;

use crate::draw;
use crate::geom;
use crate::geom::graph::node;
use crate::math::BaseFloat;
use self::spatial::dimension;
use std::cell::RefCell;
use std::ops;

pub mod color;
pub mod primitive;
pub mod spatial;

use self::spatial::dimension;

pub use self::color::SetColor;
pub use self::primitive::{Ellipse, Line, Primitive, Quad, Rect, Tri};
pub use self::spatial::dimension::SetDimensions;
pub use self::spatial::orientation::SetOrientation;
pub use self::spatial::position::SetPosition;
Expand Down

0 comments on commit 10310bd

Please sign in to comment.