polygon-art/examples/font.rs
2021-04-13 07:47:29 +02:00

35 lines
1.1 KiB
Rust

//! Shows how to use buildin font
use geo::line_string;
use polygon_art::{AsteroidFont, Context, FontDirection};
use FontDirection::{LeftRight, TopDown};
fn main() {
let context = Context::create();
context.save();
context.translate(70., 50.);
let font = AsteroidFont::new();
let line = font.get_text("Hey there!".to_string(), 12., LeftRight);
context.draw_multiline_string(&line);
context.draw_line_string(&line_string![(x : 0., y:14.), (x: 1000. , y : 14.)]);
context.translate(0.0, 18.);
let line = font.get_text("How are you?".to_string(), 22., LeftRight);
context.draw_multiline_string(&line);
context.translate(0.0, 28.);
let line = font.get_text("Here a bitter text!".to_string(), 50., LeftRight);
context.draw_multiline_string(&line);
context.translate(0.0, 56.);
let line = font.get_text("0123456789".to_string(), 50., LeftRight);
context.draw_multiline_string(&line);
context.restore();
context.translate(30., 50.);
let line = font.get_text("0123456789".to_string(), 30., TopDown);
context.draw_multiline_string(&line);
context.render();
}