Add DrawContext::draw_indexed()

This commit is contained in:
mars 2022-11-03 17:52:32 -06:00
parent a2d51b2fa8
commit 47f0894cbd
1 changed files with 18 additions and 0 deletions

View File

@ -186,6 +186,24 @@ impl DrawContext {
}
}
pub fn draw_indexed(&self, vertices: &[MeshVertex], indices: &[MeshIndex]) {
let mut vertices = vertices.to_vec();
if let Some(offset) = self.offset {
for v in vertices.iter_mut() {
v.position += offset;
}
}
if let Some(opacity) = self.opacity {
for v in vertices.iter_mut() {
v.color = v.color.alpha_multiply(opacity);
}
}
self.panel.draw_indexed(&vertices, &indices);
}
pub fn draw_triangle(&self, v1: Vec2, v2: Vec2, v3: Vec2, color: Color) {
if let Some(clip_rect) = self.clip_rect.as_ref() {
let tri = ColoredTriangle { v1, v2, v3, color };