Add TextBlock::render_to_draw_batch
use crate::prelude::{string_to_cp437, Console, Tile};
use bracket_color::prelude::RGB;
+use super::command_buffer::DrawBatch;
+use super::prelude::Point;
+use super::prelude::ColorPair;
pub struct TextBlock {
x: i32,
@@ -60,6 +63,21 @@ impl TextBlock {
}
}
+ pub fn render_to_draw_batch(&self, draw_batch: &mut DrawBatch) {
+ for y in 0..self.height {
+ for x in 0..self.width {
+ draw_batch.set(
+ Point::new(x + self.x, y + self.y),
+ ColorPair::new(
+ self.buffer[self.at(x, y)].fg,
+ self.buffer[self.at(x, y)].bg,
+ ),
+ self.buffer[self.at(x, y)].glyph,
+ );
+ }
+ }
+ }
+
pub fn print(&mut self, text: &TextBuilder) {
for cmd in &text.commands {
match cmd {
