# Module nannou::prelude [−][src]

## Expand description

A collection of commonly used items that we recommend importing for ease of use.

## Re-exports

`pub use crate::app;`

`pub use crate::app::App;`

`pub use crate::app::LoopMode;`

`pub use crate::draw::Draw;`

`pub use crate::event::WindowEvent::*;`

`pub use crate::event::AxisMotion;`

`pub use crate::event::Event;`

`pub use crate::event::TouchEvent;`

`pub use crate::event::TouchpadPressure;`

`pub use crate::event::Update;`

`pub use crate::event::WindowEvent;`

`pub use crate::frame::Frame;`

`pub use crate::frame::RawFrame;`

`pub use crate::io::load_from_json;`

`pub use crate::io::load_from_toml;`

`pub use crate::io::safe_file_save;`

`pub use crate::io::save_to_json;`

`pub use crate::io::save_to_toml;`

`pub use crate::text;`

`pub use crate::text::text;`

`pub use crate::time::DurationF64;`

`pub use crate::wgpu;`

`pub use crate::window;`

`pub use crate::window::Window;`

## Modules

Types, functions and other items related to geometry. This module is the source of all graphics and lazer primitives and aids work in 2D and 3D space.

RGB types, spaces and standards.

## Structs

A 2D affine transform, which can represent translation, rotation, scaling and shear.

A 3D affine transform, which can represent translation, rotation, scaling and shear.

A 2-dimensional boolean vector.

A 3-dimensional boolean vector.

A 4-dimensional boolean vector.

Describes a Buffer when allocating.

A light-weight `Cuboid`

type with many helper and utility methods.

A 2D affine transform, which can represent translation, rotation, scaling and shear.

A 3D affine transform, which can represent translation, rotation, scaling and shear.

A 2x2 column major matrix.

A 3x3 column major matrix.

A 4x4 column major matrix.

A quaternion representing an orientation.

A 2-dimensional vector.

A 3-dimensional vector.

A 4-dimensional vector.

Linear HSL color space.

Linear HSV color space.

A 2-dimensional vector.

A 3-dimensional vector.

A 4-dimensional vector.

A 2x2 column major matrix.

A 3x3 column major matrix.

A 3x3 column major matrix.

A 4x4 column major matrix.

A quaternion representing an orientation.

Defines a Rectangle’s bounds across the x and y axes.

A 2-dimensional vector.

A 3-dimensional vector.

A 4-dimensional vector.

A 2-dimensional vector.

A 3-dimensional vector without SIMD support.

A 3-dimensional vector with SIMD support.

A 4-dimensional vector.

Identifier of a window. Unique for each window.

## Enums

Fullscreen modes.

Symbolic name for a keyboard key.

Describes a button of a mouse controller.

Describes a difference in the mouse scroll wheel state.

Describes touch-screen input state.

## Constants

Archimedes’ constant (π)

Archimedes’ constant (π)

The full circle constant (τ)

The full circle constant (τ)

## Traits

A generic interface for casting between machine scalars with the
`as`

operator, which admits narrowing and precision loss.
Implementers of this trait `AsPrimitive`

should behave like a primitive
numeric type (e.g. a newtype around another primitive), and the
intended conversion must never fail.

Numbers which have upper and lower bounds

Performs addition that returns `None`

instead of wrapping around on
overflow.

Performs division that returns `None`

instead of panicking on division by zero and instead of
wrapping around on underflow and overflow.

Performs multiplication that returns `None`

instead of wrapping around on underflow or
overflow.

Performs negation that returns `None`

if the result can’t be represented.

Performs an integral remainder that returns `None`

instead of panicking on division by zero and
instead of wrapping around on underflow and overflow.

Performs a left shift that returns `None`

on shifts larger than
the type width.

Performs a right shift that returns `None`

on shifts larger than
the type width.

Performs subtraction that returns `None`

instead of wrapping around on underflow.

Utility methods not meant to be in the main API.

Generic trait for floating point numbers

A generic trait for converting a number to a value.

Unary operator for retrieving the multiplicative inverse, or reciprocal, of a value.

Create a transformation matrix that will cause a vector to point at `dir`

using `up`

for
orientation.

Fused multiply-add. Computes `(self * a) + b`

with only one rounding
error, yielding a more accurate result than an unfused multiply-add.

The fused multiply-add assignment operation.

The base trait for numeric types, covering `0`

and `1`

values,
comparisons, basic numeric operations, and string conversion.

The trait for `Num`

types which also implement assignment operators.

The trait for types implementing numeric assignment operators (like `+=`

).

The trait for `NumAssign`

types which also implement assignment operations
taking the second operand by reference.

An interface for casting between machine scalars.

The trait for types implementing basic numeric operations

The trait for `Num`

types which also implement numeric operations taking
the second operand by reference.

Defines a multiplicative identity element for `Self`

.

Binary operator for raising a value to a power.

Generic trait for primitive integers.

The trait for references which implement numeric operations, taking the second operand either by value or by reference.

Saturating math operations. Deprecated, use `SaturatingAdd`

, `SaturatingSub`

and
`SaturatingMul`

instead.

Performs addition that saturates at the numeric bounds instead of overflowing.

Performs multiplication that saturates at the numeric bounds instead of overflowing.

Performs subtraction that saturates at the numeric bounds instead of overflowing.

Useful functions for signed numbers (i.e. numbers that can be negative).

A generic trait for converting a value to a number.

A trait for values which cannot be negative

Short-hand for retrieving the angle of the vector in radians.

Performs addition that wraps around on overflow.

Performs multiplication that wraps around on overflow.

Performs a negation that does not panic.

Performs a left shift that does not panic.

Performs a right shift that does not panic.

Performs subtraction that wraps around on overflow.

Defines an additive identity element for `Self`

.

## Functions

Computes the absolute value.

The positive difference of two numbers.

Cast from one machine scalar to another.

Raises a value to the power of exp, returning `None`

if an overflow occurred.

Clamp a value between some range.

A value bounded by a maximum value

A value bounded by a minimum value

Convert the given angle in degrees to the same angle in radians.

Creates a 2x2 matrix from two column vectors.

Creates a 3x3 matrix from three column vectors.

Creates a 4x4 matrix from four column vectors.

Creates a quaternion from `x`

, `y`

, `z`

and `w`

values.

Creates a 2-dimensional vector.

Creates a 3-dimensional vector.

Creates a 4-dimensional vector.

Models the C++ fmod function.

A short-hand constructor for `Gray::new`

.

A short-hand constructor for `Hsl::new(RgbHue::from_degrees(h * 360.0), s, l)`

.

A short-hand constructor for `Hsla::new(RgbHue::from_degrees(h * 360.0), s, l, a)`

.

A short-hand constructor for `Hsv::new(RgbHue::from_degrees(h * 360.0), s, v)`

.

A short-hand constructor for `Hsva::new(RgbHue::from_degrees(h * 360.0), s, v, a)`

.

Creates a 2-dimensional vector.

Creates a 3-dimensional vector.

Creates a 4-dimensional vector.

A short-hand constructor for `LinSrgb::new`

.

A short-hand constructor for `LinSrgba::new`

.

Maps a value from an input range to an output range.

Creates a 2x2 matrix from two column vectors.

Creates a 3x3 matrix from three column vectors.

Creates a 3x3 matrix from three column vectors.

Creates a 4x4 matrix from four column vectors.

Returns the multiplicative identity, `1`

.

The max between two partially ordered values.

The min between two partially ordered values.

Raises a value to the power of exp, using exponentiation by squaring.

Construct a 2-dimensional point.

Construct a 3-dimensional point.

Creates a quaternion from `x`

, `y`

, `z`

and `w`

values.

Convert the given angle in radians to the same angle in degrees.

Convert the given value in radians to the equivalent value as a number of turns.

Generates a random value using the thread-local random number generator.

Generates and returns a random ascii character.

A wrapper function around the `random`

function that avoids the need for specifying a type in
the case that it cannot be inferred. The primary purpose for this is to simplify the random API
for new rust users.

A wrapper function around the `random`

function that avoids the need for specifying a type in
the case that it cannot be inferred. The primary purpose for this is to simplify the random API
for new rust users.

A function for generating a random value within the given range.

A short-hand constructor for `Rgb::new`

.

A short-hand constructor for `Rgb::<u8>::new`

.

A short-hand constructor for `Rgba::new`

.

A short-hand constructor for `Rgba<u8>::new`

.

Returns the sign of the number.

A short-hand constructor for `Srgb::new`

.

A short-hand constructor for `Srgb<u8>::new`

.

A short-hand constructor for `Srgba::new`

.

A short-hand constructor for `Srgba<u8>::new`

.

Convert the given value as a number of “turns” into the equivalent angle in radians.

Creates a 2-dimensional vector.

Creates a 3-dimensional vector.

Creates a 3-dimensional vector.

Creates a 4-dimensional vector.

Returns the additive identity, `0`

.

## Type Definitions

A color represented as gray intensity.

Linear HSL with an alpha component. See the `Hsla`

implementation in
`Alpha`

.

Linear HSV with an alpha component. See the `Hsva`

implementation in
`Alpha`

.

Linear sRGB.

Linear sRGB with an alpha component.

A 2-dimensional point type.

A 3-dimensional point type.

A color represented as red, green and blue intensities.

The same as `Rgb`

, but with `u8`

’s.

The same as `Rgb`

, but with an alpha value representing opacity.

The same as `Rgba`

, but with `u8`

’s.

Nonlinear sRGB.

Nonlinear sRGB with an alpha component.

A common alias for the `glam::Vec2`

type.

A common alias for the `glam::Vec3`

type.

A common alias for the `glam::Vec4`

type.