use graphics_buffer::*;
use pane::prelude::*;
static ROBOTO: &'static [u8] = include_bytes!("roboto.ttf");
const MESSAGE1: &str =
"Somebody once told me the world is gonna role me. I ain't the sharpest tool in the shed.";
const MESSAGE2: &str = "She was lookin' kinda dumb with her finger and her thumb";
const MESSAGE3: &str = "in the shape of an 'L' on her forehead.";
fn main() {
let mut glyphs = buffer_glyphs_from_bytes(ROBOTO).unwrap();
let format = TextFormat::new(50).color(color::WHITE);
let pane = Pane::new()
.with_rect([0.0, 0.0, 400.0, 300.0])
.with_color(color::BLACK)
.with_margin(10.0)
.with_orientation(Orientation::Horizontal)
.with_panes(vec![
Pane::new()
.with_color(color::RED)
.with_contents(Contents::text(MESSAGE1, format))
.with_margin(5.0),
Pane::new()
.with_color(color::WHITE)
.with_margin(5.0)
.with_panes(vec![
Pane::new()
.with_color(color::GREEN)
.with_contents(Contents::text(MESSAGE2, format.right()))
.with_margin(5.0),
Pane::new()
.with_color(color::BLUE)
.with_contents(Contents::text(MESSAGE3, format.centered()))
.with_margin(5.0),
]),
])
.fit_text(&mut glyphs);
let mut buffer = RenderBuffer::new(pane.rect().width() as u32, pane.rect().height() as u32);
buffer.clear([1.0, 1.0, 1.0, 1.0]);
pane.draw(&mut glyphs, IDENTITY, &mut buffer).unwrap();
buffer.save("simple.png").unwrap();
}