48 lines
1.3 KiB
Rust
48 lines
1.3 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.);
|
||
|
// context.scale(8.);
|
||
|
|
||
|
let font = AsteroidFont::new();
|
||
|
let line = font.get_text("Hey there!".to_string(), 12., LeftRight);
|
||
|
for char in line.iter() {
|
||
|
context.draw_line_string(char);
|
||
|
}
|
||
|
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);
|
||
|
for char in line.iter() {
|
||
|
context.draw_line_string(char);
|
||
|
}
|
||
|
|
||
|
context.translate(0.0, 28.);
|
||
|
let line = font.get_text("Here a bitter text!".to_string(), 50., LeftRight);
|
||
|
for char in line.iter() {
|
||
|
context.draw_line_string(char);
|
||
|
}
|
||
|
|
||
|
context.translate(0.0, 56.);
|
||
|
let line = font.get_text("0123456789".to_string(), 50., LeftRight);
|
||
|
for char in line.iter() {
|
||
|
context.draw_line_string(char);
|
||
|
}
|
||
|
|
||
|
context.restore();
|
||
|
context.translate(30., 50.);
|
||
|
let line = font.get_text("0123456789".to_string(), 30., TopDown);
|
||
|
for char in line.iter() {
|
||
|
context.draw_line_string(char);
|
||
|
}
|
||
|
|
||
|
context.render();
|
||
|
}
|