use core::hint;
use embedded_graphics::image::Image;
use embedded_graphics::mono_font::ascii::FONT_10X20;
use embedded_graphics::mono_font::MonoTextStyle;
use embedded_graphics::pixelcolor::Rgb888;
use embedded_graphics::prelude::*;
use embedded_graphics::primitives::{
Circle, PrimitiveStyle, PrimitiveStyleBuilder, StrokeAlignment, Triangle,
};
use embedded_graphics::text::{Alignment, Text};
use tinytga::Tga;
use crate::device::vga;
#[allow(unused)]
pub extern "C" fn app() -> ! {
let Ok(mut display) = vga::Display::new() else {
debug!("Could not init display!!!");
serial!("Could not init display!!!");
loop {
hint::spin_loop()
}
};
let sra_logo: Tga<Rgb888> = Tga::from_slice(include_bytes!("../assets/sra.tga")).unwrap();
let thin_stroke = PrimitiveStyle::with_stroke(RgbColor::GREEN, 1);
let thick_stroke = PrimitiveStyle::with_stroke(RgbColor::BLUE, 3);
let border_stroke = PrimitiveStyleBuilder::new()
.stroke_color(RgbColor::BLUE)
.stroke_width(3)
.stroke_alignment(StrokeAlignment::Inside)
.build();
let character_style = MonoTextStyle::new(&FONT_10X20, RgbColor::BLUE);
let mut i = 0usize;
let rect = display.bounding_box();
let center = rect.center();
loop {
rect.into_styled(border_stroke).draw(&mut display).unwrap();
Image::new(&sra_logo, Point::new(10, 10))
.draw(&mut display)
.unwrap();
let s = 120;
Triangle::new(
center + Point::new(-s * 4 / 5, s / 2),
center + Point::new(s * 4 / 5, s / 2),
center + Point::new(0, -s),
)
.into_styled(thin_stroke)
.draw(&mut display)
.unwrap();
let s = s / 2;
Triangle::new(
center + Point::new(-s * 4 / 5, -s / 2),
center + Point::new(s * 4 / 5, -s / 2),
center + Point::new(0, s),
)
.into_styled(thin_stroke)
.draw(&mut display)
.unwrap();
let d = 500 + ((i as i32 % 300) - 150).abs();
Circle::new(center - Point::new(d / 2, d / 2), d as _)
.into_styled(thick_stroke)
.draw(&mut display)
.unwrap();
let d = 450 + (((i / 2 + 30) as i32 % 200) - 100).abs();
Circle::new(center - Point::new(d / 2, d / 2), d as _)
.into_styled(thin_stroke)
.draw(&mut display)
.unwrap();
Text::with_alignment(
"Woa such graphics!",
center + Point::new(0, 0),
character_style,
Alignment::Center,
)
.draw(&mut display)
.unwrap();
display.render();
display.clear(RgbColor::BLACK).unwrap();
i = i.wrapping_add(1);
}
}