veloren_voxygen/ui/ice/renderer/widget/
compound_graphic.rs1use super::super::{
2 super::{Rotation, widget::compound_graphic},
3 IcedRenderer, Primitive,
4};
5use common::util::srgba_to_linear;
6use compound_graphic::GraphicKind;
7use iced::{Rectangle, mouse};
8
9impl compound_graphic::Renderer for IcedRenderer {
10 fn draw<I>(&mut self, graphics: I) -> Self::Output
11 where
12 I: Iterator<Item = (Rectangle, GraphicKind)>,
13 {
14 (
15 Primitive::Group {
16 primitives: graphics
17 .map(|(bounds, kind)| match kind {
18 GraphicKind::Image(handle, color) => Primitive::Image {
19 handle: (handle, Rotation::None),
20 bounds,
21 color,
22 source_rect: None,
23 },
24 GraphicKind::Color(color) => Primitive::Rectangle {
25 bounds,
26 linear_color: srgba_to_linear(color.map(|e| e as f32 / 255.0)),
27 },
28 GraphicKind::Gradient(top_color, bottom_color) => Primitive::Gradient {
29 bounds,
30 top_linear_color: srgba_to_linear(top_color.map(|e| e as f32 / 255.0)),
31 bottom_linear_color: srgba_to_linear(
32 bottom_color.map(|e| e as f32 / 255.0),
33 ),
34 },
35 })
36 .collect(),
37 },
38 mouse::Interaction::default(),
39 )
40 }
41}