#![no_main]
#![no_std]
extern crate flipperzero_rt;
extern crate flipperzero_alloc;
use core::ffi::CStr;
use core::time::Duration;
use flipperzero::furi::thread::sleep;
use flipperzero::gui::Gui;
use flipperzero_rt::{entry, manifest};
use embedded_graphics::mono_font::{ascii::FONT_6X10, MonoTextStyle};
use embedded_graphics::pixelcolor::BinaryColor;
use embedded_graphics::prelude::*;
use embedded_graphics::primitives::{
Circle, PrimitiveStyle, PrimitiveStyleBuilder, Rectangle, StrokeAlignment, Triangle,
};
use embedded_graphics::text::{Alignment, Text};
manifest!(
name = "Embedded Graphics",
app_version = 1,
has_icon = true,
icon = "icons/rustacean-10x10.icon",
);
entry!(main);
fn main(_args: Option<&CStr>) -> i32 {
let gui = Gui::open();
let mut canvas = gui.direct_draw_acquire();
let thin_stroke = PrimitiveStyle::with_stroke(BinaryColor::On, 1);
let thick_stroke = PrimitiveStyle::with_stroke(BinaryColor::On, 3);
let border_stroke = PrimitiveStyleBuilder::new()
.stroke_color(BinaryColor::On)
.stroke_width(3)
.stroke_alignment(StrokeAlignment::Inside)
.build();
let fill = PrimitiveStyle::with_fill(BinaryColor::On);
let character_style = MonoTextStyle::new(&FONT_6X10, BinaryColor::On);
let yoffset = 14;
canvas
.bounding_box()
.into_styled(border_stroke)
.draw(&mut *canvas)
.unwrap();
Triangle::new(
Point::new(16, 16 + yoffset),
Point::new(16 + 16, 16 + yoffset),
Point::new(16 + 8, yoffset),
)
.into_styled(thin_stroke)
.draw(&mut *canvas)
.unwrap();
Rectangle::new(Point::new(52, yoffset), Size::new(16, 16))
.into_styled(fill)
.draw(&mut *canvas)
.unwrap();
Circle::new(Point::new(88, yoffset), 17)
.into_styled(thick_stroke)
.draw(&mut *canvas)
.unwrap();
let text = "embedded-graphics";
Text::with_alignment(
text,
canvas.bounding_box().center() + Point::new(0, 15),
character_style,
Alignment::Center,
)
.draw(&mut *canvas)
.unwrap();
canvas.commit();
sleep(Duration::from_secs(5));
0
}