Skip to content

Commit 13502b7

Browse files
committed
Fix upside down display
1 parent 9de3194 commit 13502b7

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/cmd/display.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use anyhow::Result;
33
use clap::{command, Parser};
44
use crossterm::event::{Event, EventStream, KeyCode, KeyEventKind};
55
use futures::{select, StreamExt};
6-
use lighthouse_client::protocol::{Frame, InputEvent, Model};
6+
use lighthouse_client::protocol::{Frame, InputEvent, Model, LIGHTHOUSE_COLS, LIGHTHOUSE_ROWS};
77
use ratatui::{
88
backend::CrosstermBackend,
99
crossterm::{
@@ -95,16 +95,16 @@ fn draw_to_canvas(frame: Frame, max_width: f64, max_height: f64, title: String)
9595
)
9696
.marker(Marker::Block)
9797
.paint(move |ctx| {
98-
for y in 0..14 {
99-
for x in 0..28 {
98+
for y in 0..LIGHTHOUSE_ROWS {
99+
for x in 0..LIGHTHOUSE_COLS {
100100
let c = frame.get(x, y);
101101
ctx.draw(&Rectangle {
102102
x: x as f64,
103-
y: y as f64,
103+
y: (LIGHTHOUSE_ROWS - 1 - y) as f64,
104104
width: 1.0,
105105
height: 1.0,
106106
color: Color::from_u32(
107-
c.blue as u32 | (c.green as u32) << 8 | (c.red as u32) << 16,
107+
((c.red as u32) << 16) | (c.green as u32) << 8 | c.blue as u32,
108108
),
109109
})
110110
}

0 commit comments

Comments
 (0)