Fixed some importing issues since you can use a Shader::Gradient outside a Canvas widget, where it was previously only accessible.

This commit is contained in:
shan 2022-09-30 10:27:00 -07:00
parent e25f3d3dea
commit 5d0fffc626
11 changed files with 126 additions and 148 deletions

View file

@ -335,7 +335,7 @@ impl Frame {
if !buffer.indices.is_empty() {
self.primitives.push(Primitive::Mesh2D {
buffers: triangle::Mesh2D {
vertices: Vertex2D::from(buffer.vertices),
vertices: vertices_from(buffer.vertices),
indices: buffer.indices,
},
size: self.size,
@ -347,3 +347,8 @@ impl Frame {
self.primitives
}
}
/// Converts from [`lyon::math::Point`] to [`Vertex2D`]. Used for generating primitives.
fn vertices_from(points: Vec<lyon::math::Point>) -> Vec<Vertex2D> {
points.iter().map(|p| Vertex2D { position: [p.x, p.y]}).collect()
}