1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
use core::marker::PhantomData;
use embedded_graphics::prelude::*;
use crate::RawPixels;
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)]
pub struct Pixels<'a, 'b, C> {
raw: RawPixels<'a, 'b>,
color_type: PhantomData<C>,
}
impl<'a, 'b, C> Pixels<'a, 'b, C> {
pub(crate) fn new(raw: RawPixels<'a, 'b>) -> Self {
Self {
raw,
color_type: PhantomData,
}
}
}
impl<C> Iterator for Pixels<'_, '_, C>
where
C: PixelColor + From<<C as PixelColor>::Raw>,
{
type Item = Pixel<C>;
fn next(&mut self) -> Option<Self::Item> {
self.raw
.next()
.map(|p| Pixel(p.position, C::Raw::from_u32(p.color).into()))
}
}