pub struct Mesh { /* private fields */ }Expand description
2D polygon mesh.
All of its creation methods are just shortcuts for doing the same operation
via a MeshBuilder.
Implementations§
Source§impl Mesh
impl Mesh
Sourcepub fn new_line<P>(
ctx: &mut Context,
quad_ctx: &mut GraphicsContext,
points: &[P],
width: f32,
color: Color,
) -> GameResult<Mesh>
pub fn new_line<P>( ctx: &mut Context, quad_ctx: &mut GraphicsContext, points: &[P], width: f32, color: Color, ) -> GameResult<Mesh>
Create a new mesh for a line of one or more connected segments.
Sourcepub fn new_circle<P>(
ctx: &mut Context,
quad_ctx: &mut GraphicsContext,
mode: DrawMode,
point: P,
radius: f32,
tolerance: f32,
color: Color,
) -> GameResult<Mesh>
pub fn new_circle<P>( ctx: &mut Context, quad_ctx: &mut GraphicsContext, mode: DrawMode, point: P, radius: f32, tolerance: f32, color: Color, ) -> GameResult<Mesh>
Create a new mesh for a circle.
Sourcepub fn new_ellipse<P>(
ctx: &mut Context,
quad_ctx: &mut GraphicsContext,
mode: DrawMode,
point: P,
radius1: f32,
radius2: f32,
tolerance: f32,
color: Color,
) -> GameResult<Mesh>
pub fn new_ellipse<P>( ctx: &mut Context, quad_ctx: &mut GraphicsContext, mode: DrawMode, point: P, radius1: f32, radius2: f32, tolerance: f32, color: Color, ) -> GameResult<Mesh>
Create a new mesh for an ellipse.
Sourcepub fn new_polyline<P>(
ctx: &mut Context,
quad_ctx: &mut GraphicsContext,
mode: DrawMode,
points: &[P],
color: Color,
) -> GameResult<Mesh>
pub fn new_polyline<P>( ctx: &mut Context, quad_ctx: &mut GraphicsContext, mode: DrawMode, points: &[P], color: Color, ) -> GameResult<Mesh>
Create a new mesh for series of connected lines.
Sourcepub fn new_polygon<P>(
ctx: &mut Context,
quad_ctx: &mut GraphicsContext,
mode: DrawMode,
points: &[P],
color: Color,
) -> GameResult<Mesh>
pub fn new_polygon<P>( ctx: &mut Context, quad_ctx: &mut GraphicsContext, mode: DrawMode, points: &[P], color: Color, ) -> GameResult<Mesh>
Create a new mesh for closed polygon. The points given must be in clockwise order, otherwise at best the polygon will not draw.
Sourcepub fn new_rectangle(
ctx: &mut Context,
quad_ctx: &mut GraphicsContext,
mode: DrawMode,
bounds: Rect,
color: Color,
) -> GameResult<Mesh>
pub fn new_rectangle( ctx: &mut Context, quad_ctx: &mut GraphicsContext, mode: DrawMode, bounds: Rect, color: Color, ) -> GameResult<Mesh>
Create a new mesh for a rectangle
Sourcepub fn new_rounded_rectangle(
ctx: &mut Context,
quad_ctx: &mut GraphicsContext,
mode: DrawMode,
bounds: Rect,
radius: f32,
color: Color,
) -> GameResult<Mesh>
pub fn new_rounded_rectangle( ctx: &mut Context, quad_ctx: &mut GraphicsContext, mode: DrawMode, bounds: Rect, radius: f32, color: Color, ) -> GameResult<Mesh>
Create a new mesh for a rounded rectangle
Sourcepub fn from_triangles<P>(
ctx: &mut Context,
quad_ctx: &mut GraphicsContext,
triangles: &[P],
color: Color,
) -> GameResult<Mesh>
pub fn from_triangles<P>( ctx: &mut Context, quad_ctx: &mut GraphicsContext, triangles: &[P], color: Color, ) -> GameResult<Mesh>
Create a new Mesh from a raw list of triangle points.
Sourcepub fn from_raw<V>(
ctx: &mut Context,
quad_ctx: &mut GraphicsContext,
verts: &[V],
indices: &[u16],
image: Option<Image>,
) -> GameResult<Mesh>
pub fn from_raw<V>( ctx: &mut Context, quad_ctx: &mut GraphicsContext, verts: &[V], indices: &[u16], image: Option<Image>, ) -> GameResult<Mesh>
Creates a Mesh from a raw list of triangles defined from points
and indices, with the given UV texture coordinates. You may also
supply an Image to use as a texture, if you pass None, it will
just use a pure white texture.
This is the most primitive mesh-creation method, but allows you full control over the tesselation and texturing. As such it will panic or produce incorrect/invalid output (that may later cause drawing to panic), if:
indicescontains a value out of bounds ofvertsvertsis longer thanu16::MAXelements.
Trait Implementations§
Source§impl Drawable for Mesh
impl Drawable for Mesh
Source§fn draw(
&self,
ctx: &mut Context,
quad_ctx: &mut GraphicsContext,
param: DrawParam,
) -> GameResult
fn draw( &self, ctx: &mut Context, quad_ctx: &mut GraphicsContext, param: DrawParam, ) -> GameResult
Source§fn set_blend_mode(&mut self, mode: Option<BlendMode>)
fn set_blend_mode(&mut self, mode: Option<BlendMode>)
graphics::set_blend_mode().
If None is set, defers to the blend mode set by
graphics::set_blend_mode().Source§fn blend_mode(&self) -> Option<BlendMode>
fn blend_mode(&self) -> Option<BlendMode>
fn dimensions(&self, _ctx: &mut Context) -> Option<Rect>
Auto Trait Implementations§
impl Freeze for Mesh
impl RefUnwindSafe for Mesh
impl Send for Mesh
impl Sync for Mesh
impl Unpin for Mesh
impl UnwindSafe for Mesh
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more