use embedded_graphics::{
fonts::{Font8x16, Text},
image::{Image, ImageRaw, ImageRawLE},
pixelcolor::Rgb565,
prelude::*,
primitives::rectangle::Rectangle,
style::{PrimitiveStyleBuilder, TextStyle},
};
use raqote_display::prelude::*;
use orbclient::*;
pub fn main() {
let width = 160;
let height = 128;
let (screen_width, screen_height) = orbclient::get_display_size().unwrap();
let mut display = RaqoteDisplay::new(width, height).unwrap();
let style = PrimitiveStyleBuilder::new()
.fill_color(Rgb565::BLACK)
.build();
let black_backdrop = Rectangle::new(Point::new(0, 0), Point::new(160, 128)).into_styled(style);
black_backdrop.draw(&mut display).unwrap();
let image_raw: ImageRawLE<Rgb565> =
ImageRaw::new(include_bytes!("../assets/ferris.raw"), 86, 64);
let image: Image<_, Rgb565> = Image::new(&image_raw, Point::new(34, 8));
image.draw(&mut display).unwrap();
Text::new("raqote-display!", Point::new(20, 95))
.into_styled(TextStyle::new(Font8x16, Rgb565::WHITE))
.draw(&mut display)
.unwrap();
let mut window = Window::new(
((screen_width - width) / 2) as i32,
((screen_height - height) / 2) as i32,
width,
height,
"RaqoteDisplay - minimal example",
)
.unwrap();
let mut surface = vec![0; window.data().len()];
display.flip(&mut surface);
let color_data: Vec<orbclient::Color> = surface
.iter()
.map(|p| orbclient::Color { data: *p })
.collect();
window.data_mut().clone_from_slice(color_data.as_slice());
window.sync();
'events: loop {
for event in window.events() {
match event.to_option() {
EventOption::Quit(_quit_event) => break 'events,
EventOption::Mouse(evt) => println!(
"At position {:?} pixel color is : {:?}",
(evt.x, evt.y),
window.getpixel(evt.x, evt.y)
),
event_option => println!("{:?}", event_option),
}
}
}
}