[][src]Struct nannou::draw::Draw

pub struct Draw<S = Default> where
    S: BaseFloat
{ /* fields omitted */ }

A simple API for drawing 2D and 3D graphics.

Draw provides a simple way to compose together geometric primitives and text (TODO) with custom colours and textures and draw them to the screen.

You can also ask Draw for the sequence of vertices or triangles (with or without colours/textures) that make up the entire scene that you have created.

Internally Draw uses a geom::Graph for placing geometry and text in 3D space.

Draw has 2 groups of methods:

  1. Creation: These methods compose new geometry and text with colours and textures.

  2. Rendering: These methods provide ways of rendering the graphics either directly to the frame for the current display or to a list of vertices or triangles for lower-level, more flexible access.

See the simple_draw.rs example for a demonstration of how to use the App's custom Draw type.

Methods

impl<S> Draw<S> where
    S: BaseFloat
[src]

pub fn new() -> Self[src]

Create a new Draw instance.

This is the same as calling Draw::default.

pub fn reset(&self)[src]

Resets all state within the Draw instance.

pub fn background(&self) -> Background<S>[src]

Specify a color with which the background should be cleared.

pub fn a<T>(&self, primitive: T) -> Drawing<T, S> where
    T: IntoDrawn<S> + Into<Primitive<S>>,
    Primitive<S>: Into<Option<T>>, 
[src]

Add the given type to be drawn.

pub fn ellipse(&self) -> Drawing<Ellipse<S>, S>[src]

Begin drawing an Ellipse.

pub fn line(&self) -> Drawing<Line<S>, S>[src]

Begin drawing a Line.

pub fn quad(&self) -> Drawing<Quad<S>, S>[src]

Begin drawing a Quad.

pub fn rect(&self) -> Drawing<Rect<S>, S>[src]

Begin drawing a Rect.

pub fn tri(&self) -> Drawing<Tri<S>, S>[src]

Begin drawing a Triangle.

pub fn polygon(&self) -> Drawing<Pointless, S>[src]

Begin drawing a Polygon.

pub fn mesh(&self) -> Drawing<Vertexless, S>[src]

Begin drawing a Mesh.

pub fn polyline(&self) -> Drawing<Vertexless, S>[src]

Begin drawing a Polyline.

pub fn node_vertices(&self, n: Index) -> Option<NodeVertices<S>>[src]

Produce the transformed mesh vertices for the node at the given index.

Returns None if there is no node for the given index.

pub fn node_triangles(&self, n: Index) -> Option<NodeTriangles<S>>[src]

Produce the transformed triangles for the node at the given index.

Note: If the node's Drawing was still in progress, it will first be finished and inserted into the mesh and geometry graph before producing the triangles iterator.

Important traits for RawVertices<'a, S>
pub fn raw_vertices(&self) -> RawVertices<S>[src]

Produce an iterator yielding all vertices from the inner mesh transformed via the inner geometry graph.

This method ignores the mesh indices buffer and instead produces the vertices "raw".

Note: If there are any Drawings in progress, these will first be drained and completed before any vertices are yielded.

Important traits for Vertices<'a, S>
pub fn vertices(&self) -> Vertices<S>[src]

Produce an iterator yielding all indexed vertices from the inner mesh transformed via the inner geometry graph.

Vertices are yielded in depth-first-order of the geometry graph nodes from which they are produced.

Note: If there are any Drawings in progress, these will first be drained and completed before any vertices are yielded.

pub fn triangles(&self) -> Triangles<S>[src]

Produce an iterator yielding all triangles from the inner mesh transformed via the inner geometry graph.

Triangles are yielded in depth-first-order of the geometry graph nodes from which they are produced.

Note: If there are any Drawings in progress, these will first be drained and completed before any vertices are yielded.

pub fn inner_mesh(&self) -> Ref<Mesh<S>>[src]

Borrow the Draw's inner Mesh.

pub fn untransformed_dimension_of<F>(
    &self,
    n: &Index,
    point_axis: &F
) -> Option<S> where
    F: Fn(&Point<S>) -> S, 
[src]

The length of the untransformed node at the given index along the axis returned by the given point_axis function.

pub fn untransformed_x_dimension_of(&self, n: &Index) -> Option<S>[src]

The length of the untransformed node at the given index along the x axis.

pub fn untransformed_y_dimension_of(&self, n: &Index) -> Option<S>[src]

The length of the untransformed node at the given index along the y axis.

pub fn untransformed_z_dimension_of(&self, n: &Index) -> Option<S>[src]

The length of the untransformed node at the given index along the y axis.

pub fn untransformed_dimensions_of(&self, n: &Index) -> Option<Vector3<S>>[src]

Determine the raw, untransformed dimensions of the node at the given index.

Returns None if their is no node within the geom::Graph for the given index or if the node has not yet been Drawn.

pub fn dimension_of<F>(&self, n: &Index, point_axis: &F) -> Option<S> where
    F: Fn(&Point<S>) -> S, 
[src]

The length of the transformed node at the given index along the axis returned by the given point_axis function.

pub fn x_dimension_of(&self, n: &Index) -> Option<S>[src]

The length of the transformed node at the given index along the x axis.

pub fn y_dimension_of(&self, n: &Index) -> Option<S>[src]

The length of the transformed node at the given index along the y axis.

pub fn z_dimension_of(&self, n: &Index) -> Option<S>[src]

The length of the transformed node at the given index along the z axis.

pub fn finish_remaining_drawings(&self) -> Result<(), WouldCycle<S>>[src]

Drain any remaining drawings, convert them to their Drawn state and insert them into the inner mesh and geometry graph.

Trait Implementations

impl<S: Clone> Clone for Draw<S> where
    S: BaseFloat
[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl<S> Default for Draw<S> where
    S: BaseFloat
[src]

impl<S: Debug> Debug for Draw<S> where
    S: BaseFloat
[src]

Auto Trait Implementations

impl<S> Send for Draw<S> where
    S: Send

impl<S = f32> !Sync for Draw<S>

Blanket Implementations

impl<T> From<T> for T[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Content for T[src]

impl<T> SafeBorrow<T> for T[src]

impl<S> FromSample<S> for S[src]

impl<T, U> ToSample<U> for T where
    U: FromSample<T>, 
[src]

impl<S, T> Duplex<S> for T where
    T: FromSample<S> + ToSample<S>, 
[src]

impl<T> SetParameter for T

fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Result where
    T: Parameter<Self>, 

Sets value as a parameter of self.

impl<T> SetParameter for T

fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Result where
    T: Parameter<Self>, 

Sets value as a parameter of self.