pub struct Vertices { /* private fields */ }Expand description
A mesh of triangles in user space, with optional texture coordinates.
Texture coordinates run from zero to one across the image and are read per vertex, which is the point of supplying them: every other way of drawing an image here maps it by position, and a mesh that wanted that mapping would not need coordinates at all.
Implementations§
Source§impl Vertices
impl Vertices
Sourcepub fn new(mode: VertexMode, positions: Vec<Vec2>) -> Result<Vertices, Error>
pub fn new(mode: VertexMode, positions: Vec<Vec2>) -> Result<Vertices, Error>
A mesh from positions alone, filled by the paint.
The paint is sampled by position, as it is for any shape: a gradient runs across the mesh the way it would across a path covering the same area.
Sourcepub fn textured(
mode: VertexMode,
positions: Vec<Vec2>,
texture_coords: Vec<Vec2>,
) -> Result<Vertices, Error>
pub fn textured( mode: VertexMode, positions: Vec<Vec2>, texture_coords: Vec<Vec2>, ) -> Result<Vertices, Error>
A mesh whose vertices name where in the paint they read.
Any shader reads there, which is what dart:ui means by a color source
at a mesh’s coordinates: an image samples its texture, a gradient
measures its ramp, and a caller’s program receives them as uv beside
the clip position and chooses. This used to say “requires an image
paint”, which was true of neither the last two.
Sourcepub fn colored(
mode: VertexMode,
positions: Vec<Vec2>,
colors: Vec<Color>,
) -> Result<Vertices, Error>
pub fn colored( mode: VertexMode, positions: Vec<Vec2>, colors: Vec<Color>, ) -> Result<Vertices, Error>
A mesh whose vertices each carry a color.
The color multiplies whatever the paint produced, so a white paint
leaves the mesh’s own colors, and a gradient paint is shaded by them.
Multiplying is the only combination offered: dart:ui takes a blend
mode here, and every other mode either discards one of the two inputs
or is not expressible without a second value per fragment.
Sourcepub fn indexed(
mode: VertexMode,
positions: Vec<Vec2>,
texture_coords: Vec<Vec2>,
indices: Vec<u32>,
) -> Result<Vertices, Error>
pub fn indexed( mode: VertexMode, positions: Vec<Vec2>, texture_coords: Vec<Vec2>, indices: Vec<u32>, ) -> Result<Vertices, Error>
The same, with the triangles named by index rather than by order.
Sourcepub fn full(
mode: VertexMode,
positions: Vec<Vec2>,
texture_coords: Vec<Vec2>,
colors: Vec<Color>,
indices: Vec<u32>,
) -> Result<Vertices, Error>
pub fn full( mode: VertexMode, positions: Vec<Vec2>, texture_coords: Vec<Vec2>, colors: Vec<Color>, indices: Vec<u32>, ) -> Result<Vertices, Error>
Everything at once, for a caller who has all of it.
pub fn positions(&self) -> &[Vec2]
Sourcepub fn texture_coords(&self) -> &[Vec2]
pub fn texture_coords(&self) -> &[Vec2]
Texture coordinates, or empty where the mesh carries none.
Sourcepub fn indices(&self) -> &[u32]
pub fn indices(&self) -> &[u32]
Triangle indices, three per triangle, whatever mode built them.