pub struct Mesh2D {
pub vertices: Vec<Point2D>,
pub indices: Vec<u32>,
}Expand description
A 2D triangle mesh
Fields§
§vertices: Vec<Point2D>§indices: Vec<u32>Implementations§
Source§impl Mesh2D
impl Mesh2D
pub fn new() -> Self
Sourcepub fn triangle_count(&self) -> usize
pub fn triangle_count(&self) -> usize
Get the number of triangles in the mesh
Sourcepub fn extrude(&self, outline: &Outline2D, depth: f32) -> Result<Mesh3D>
pub fn extrude(&self, outline: &Outline2D, depth: f32) -> Result<Mesh3D>
Extrude this 2D mesh into a 3D mesh (fluent API)
§Arguments
outline- The linearized outline (used for side geometry)depth- The extrusion depth
§Returns
A 3D triangle mesh with normals
§Example
use fontmesh::Font;
let font = Font::from_bytes(include_bytes!("../assets/test_font.ttf"))?;
let glyph = font.glyph_by_char('A')?;
let outline = glyph.with_subdivisions(30).to_outline()?;
let mesh_2d = outline.triangulate()?;
let mesh_3d = mesh_2d.extrude(&outline, 5.0)?;Trait Implementations§
Source§impl<'de> Deserialize<'de> for Mesh2D
impl<'de> Deserialize<'de> for Mesh2D
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for Mesh2D
impl RefUnwindSafe for Mesh2D
impl Send for Mesh2D
impl Sync for Mesh2D
impl Unpin for Mesh2D
impl UnwindSafe for Mesh2D
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
Mutably borrows from an owned value. Read more