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

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 geometry and text with custom colours and textures and draw them to the screen. A suite of methods have been provided for drawing polygons, paths, meshes, text and textures in an accessible-yet-efficient manner.

Draw can also be used to create new Draw instances that refer to the same inner draw state but are slightly different from one another. E.g. draw.rotate(radians) produces a new Draw instance where all drawings will be rotated by the given amount. draw.x(x) produces a new Draw instance where all drawings are translated along the x axis by the given amount.

See the draw examples for a variety of demonstrations of how the Draw type can be used!

Implementations

impl Draw[src]

pub fn to_frame(&self, app: &App, frame: &Frame<'_>) -> Result<(), DrawError>[src]

Render the Draw’s inner list of commands to the texture associated with the Frame.

The App stores a unique render.

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 transform(&self, transform_matrix: Matrix4<S>) -> Self[src]

Produce a new Draw instance transformed by the given transform matrix.

The resulting Draw instance will be have a transform equal to the new transform applied to the existing transform.

pub fn translate(&self, v: Vector3<S>) -> Self[src]

Translate the position of the origin by the given translation vector.

pub fn xyz(&self, v: Vector3<S>) -> Self[src]

Translate the position of the origin by the given translation vector.

This method is short for translate.

pub fn xy(&self, v: Vector2<S>) -> Self[src]

Translate the position of the origin by the given translation vector.

pub fn x_y_z(&self, x: S, y: S, z: S) -> Self[src]

Translate the position of the origin by the given amount across each axis.

pub fn x_y(&self, x: S, y: S) -> Self[src]

Translate the position of the origin by the given amount across each axis.

pub fn x(&self, x: S) -> Self[src]

Translate the position of the origin along the x axis.

pub fn y(&self, y: S) -> Self[src]

Translate the position of the origin along the y axis.

pub fn z(&self, z: S) -> Self[src]

Translate the position of the origin along the z axis.

pub fn scale(&self, s: S) -> Self[src]

Produce a new Draw instance where the contents are scaled uniformly by the given value.

pub fn scale_axes(&self, v: Vector3<S>) -> Self[src]

Produce a new Draw instance where the contents are scaled by the given amount across each axis.

pub fn scale_x(&self, s: S) -> Self[src]

Produce a new Draw instance where the contents are scaled by the given amount along the x axis

pub fn scale_y(&self, s: S) -> Self[src]

Produce a new Draw instance where the contents are scaled by the given amount along the y axis

pub fn scale_z(&self, s: S) -> Self[src]

Produce a new Draw instance where the contents are scaled by the given amount along the z axis

pub fn euler(&self, euler: Euler<Rad<S>>) -> Self[src]

The given vector is interpreted as a Euler angle in radians and a transform is applied accordingly.

pub fn quaternion(&self, q: Quaternion<S>) -> Self[src]

Specify the orientation with the given Quaternion.

pub fn radians(&self, v: Vector3<S>) -> Self[src]

Specify the orientation along each axis with the given Vector of radians.

This currently has the same affect as calling euler.

pub fn x_radians(&self, x: S) -> Self[src]

Specify the orientation around the x axis in radians.

pub fn y_radians(&self, y: S) -> Self[src]

Specify the orientation around the y axis in radians.

pub fn z_radians(&self, z: S) -> Self[src]

Specify the orientation around the z axis in radians.

pub fn degrees(&self, v: Vector3<S>) -> Self[src]

Specify the orientation along each axis with the given Vector of degrees.

pub fn x_degrees(&self, x: S) -> Self[src]

Specify the orientation around the x axis in degrees.

pub fn y_degrees(&self, y: S) -> Self[src]

Specify the orientation around the y axis in degrees.

pub fn z_degrees(&self, z: S) -> Self[src]

Specify the orientation around the z axis in degrees.

pub fn turns(&self, v: Vector3<S>) -> Self[src]

Specify the orientation along each axis with the given Vector of degrees.

pub fn x_turns(&self, x: S) -> Self[src]

Specify the orientation around the x axis as a number of turns around the axis.

pub fn y_turns(&self, y: S) -> Self[src]

Specify the orientation around the y axis as a number of turns around the axis.

pub fn z_turns(&self, z: S) -> Self[src]

Specify the orientation around the z axis as a number of turns around the axis.

pub fn pitch(&self, pitch: S) -> Self[src]

Specify the “pitch” of the orientation in radians.

This has the same effect as calling x_radians.

pub fn yaw(&self, yaw: S) -> Self[src]

Specify the “yaw” of the orientation in radians.

This has the same effect as calling y_radians.

pub fn roll(&self, roll: S) -> Self[src]

Specify the “roll” of the orientation in radians.

This has the same effect as calling z_radians.

pub fn rotate(&self, radians: S) -> Self[src]

Assuming we’re looking at a 2D plane, positive values cause a clockwise rotation where the given value is specified in radians.

This is equivalent to calling the z_radians or roll methods.

pub fn alpha_blend(&self, blend_descriptor: BlendState) -> Self[src]

Produce a new Draw instance that will draw with the given alpha blend descriptor.

pub fn color_blend(&self, blend_descriptor: BlendState) -> Self[src]

Produce a new Draw instance that will draw with the given color blend descriptor.

pub fn blend(&self, blend_descriptor: BlendState) -> Self[src]

Short-hand for color_blend, the common use-case.

pub fn scissor(&self, scissor: Rect<S>) -> Self[src]

Produce a new Draw instance that will be cropped to the given rectangle.

If the current Draw instance already contains a scissor, the result will be the overlap between the original scissor and the new one.

pub fn line_mode(&self) -> Self[src]

Produce a new Draw instance.

All drawing that occurs on the new instance will be rendered as a “wireframe” between all vertices.

This will cause the draw::Renderer to switch render pipelines in order to use the LineList primitive topology. The switch will only occur if this topology was not already enabled.

pub fn point_mode(&self) -> Self[src]

Produce a new Draw instance.

All drawing that occurs on the new instance will be rendered as points on the vertices.

This will cause the draw::Renderer to switch render pipelines in order to use the PointList primitive topology. The switch will only occur if this topology was not already enabled.

pub fn triangle_mode(&self) -> Self[src]

Produce a new Draw instance.

All drawing that occurs on the new instance will be rendered as points on the vertices.

This will cause the draw::Renderer to switch render pipelines in order to use the PointList primitive topology. The switch will only occur if this topology was not already enabled.

This is the default primitive topology mode.

pub fn sampler(&self, desc: SamplerDescriptor<'static>) -> Self[src]

Produce a new Draw instance where all textures and textured vertices drawn will be sampled via a sampler of the given descriptor.

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: Into<Primitive<S>>,
    Primitive<S>: Into<Option<T>>, 
[src]

Add the given type to be drawn.

pub fn path(&self) -> Drawing<'_, PathInit<S>, S>[src]

Begin drawing a Path.

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 arrow(&self) -> Drawing<'_, Arrow<S>, S>[src]

Begin drawing an Arrow.

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<'_, PolygonInit<S>, S>[src]

Begin drawing a Polygon.

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

Begin drawing a Mesh.

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

Begin drawing a Polyline.

Note that this is simply short-hand for draw.path().stroke()

pub fn text(&self, s: &str) -> Drawing<'_, Text<S>, S>[src]

Begin drawing a Text.

pub fn texture(&self, view: &dyn ToTextureView) -> Drawing<'_, Texture<S>, S>[src]

Begin drawing a Texture.

pub fn drain_commands(&self) -> impl Iterator<Item = DrawCommand<S>>[src]

Finish any drawings-in-progress and produce an iterator draining the inner draw commands and yielding them by value.

pub fn finish_remaining_drawings(&self)[src]

Drain any remaining drawings and convert them to draw commands.

Trait Implementations

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

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

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

Auto Trait Implementations

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

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

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

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

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

Blanket Implementations

impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for S where
    T: Component + Float,
    D: AdaptFrom<S, Swp, Dwp, T>,
    Swp: WhitePoint,
    Dwp: WhitePoint
[src]

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

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

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

impl<T, U> ConvertInto<U> for T where
    U: ConvertFrom<T>, 
[src]

impl<T> Downcast<T> for T

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

impl<T> Instrument for T[src]

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

impl<T> Pointable for T

type Init = T

The type for initializers.

impl<T> SetParameter for T

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

type Owned = T

The resulting type after obtaining ownership.

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> Upcast<T> for T

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,