[oden] Color and position for text

This commit is contained in:
John Doty 2023-08-31 20:39:07 -07:00
parent 079006acdc
commit a08bc07cbb
6 changed files with 29 additions and 17 deletions

View file

@ -8,6 +8,7 @@ use std::sync::Arc;
#[derive(Debug)]
pub struct PrintCommand {
pub text: String,
pub pos: [f32; 2],
}
#[derive(Debug)]
@ -63,10 +64,10 @@ impl GraphicsImpl {
}
}
fn print(&self, text: String) -> () {
fn print(&self, text: String, x: f32, y: f32) -> () {
let _ = self
.sender
.send(GraphicsCommand::Print(PrintCommand { text }));
.send(GraphicsCommand::Print(PrintCommand { text, pos: [x, y] }));
}
fn cls(&self, r: f64, g: f64, b: f64) -> () {
@ -168,7 +169,7 @@ impl GraphicsAPI {
let gfx = gfx.clone();
builder.export(
"print",
ctx.new_fn(move |_: &ContextRef, t: String| gfx.print(t))?,
ctx.new_fn(move |_: &ContextRef, t: String, x: f32, y: f32| gfx.print(t, x, y))?,
)?;
}
{