pos f32 to pos usize

This commit is contained in:
lemon-cat committed 2026-05-14 12:22:29 +03:00
1 parent 6534ed18b4
commit 7da7d578e1
1 file changed
+9 -4
+9 -4
View File
@@ -1,4 +1,5 @@
use std::{
error,
io::{Stdout, Write, stdout},
process::Output,
};
@@ -13,7 +14,7 @@ use crossterm::{
pub struct Render {
out: Stdout,
rez: (usize, usize),
pos: (f32, f32),
pos: (usize, usize),
}
impl Render {
@@ -21,13 +22,17 @@ impl Render {
Render {
out: stdout(),
rez: (10, 10),
pos: (0.0, 0.0),
pos: (0, 0),
}
}
pub fn set_rez(&mut self, a: usize, b: usize) {
pub fn set_rez(&mut self, a: usize, b: usize) -> Result<(), String> {
if a == 0 || b == 0 {
return Err("Invalid resolution\n".to_string());
}
self.rez = (a, b);
Ok(())
}
pub fn set_pos(&mut self, a: f32, b: f32) {
pub fn set_pos(&mut self, a: usize, b: usize) {
self.pos = (a, b);
}
pub fn init(&mut self) {