small software-rendered rust tty
use faster function for character overlay
bendn 9 months ago
parent e84b363 · commit 923910a
-rw-r--r--Cargo.toml1
-rw-r--r--src/render.rs14
-rw-r--r--src/term.rs10
3 files changed, 10 insertions, 15 deletions
diff --git a/Cargo.toml b/Cargo.toml
index 086dae6..c5c94a2 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -13,6 +13,7 @@ chumsky = { git = "https://github.com/zesterer/chumsky", version = "0.11.0", fea
color-hex = "0.2.0"
ctlfun = { git = "https://github.com/bend-n/ctlfun" }
fimg = { git = "https://github.com/bend-n/fimg" }
+
implicit-fn = "0.1.0"
libc = "0.2.172"
minifb = "0.28.0"
diff --git a/src/render.rs b/src/render.rs
index 35ba979..0f4a582 100644
--- a/src/render.rs
+++ b/src/render.rs
@@ -90,20 +90,14 @@ pub fn render(
if x.placement.width == 0 {
continue;
}
-
- let item = Image::<_, 4>::build(
+ let item = Image::<_, 1>::build(
x.placement.width,
x.placement.height,
)
- .buf(
- x.data
- .iter()
- .flat_map(|&x| color.join(x))
- .collect::<Vec<u8>>(),
- );
-
- i.as_mut().overlay_blended_at(
+ .buf_unchecked(x.data);
+ i.as_mut().blend_alpha_and_color_at(
&item.as_ref(),
+ color,
4 + ((j as f32 * sz) + x.placement.left as f32)
as u32,
((k as f32 * (ppem * 1.25)) as u32)
diff --git a/src/term.rs b/src/term.rs
index 2196618..9130beb 100644
--- a/src/term.rs
+++ b/src/term.rs
@@ -70,11 +70,11 @@ impl Terminal {
let c = self.cells.get_at(self.cursor);
c.letter = Some(x);
c.style = self.style;
- eprintln!(
- "@ {:?} (mx {w}) c={}",
- self.cursor,
- c.letter.unwrap()
- );
+ // eprintln!(
+ // "@ {:?} (mx {w}) c={}",
+ // self.cursor,
+ // c.letter.unwrap()
+ // );
self.cursor.0 += 1;
}
Control(ControlFunction {