restructure with windows
This commit is contained in:
parent
fe4543ae41
commit
64f4ea529a
1 changed files with 68 additions and 130 deletions
27
src/bar.rs
27
src/bar.rs
|
|
@ -1,6 +1,5 @@
|
|||
use crate::queue::PacketQueue;
|
||||
use crate::{Currency, GenerateCommands, Progressable};
|
||||
use servicepoint::{Bitmap, BitmapCommand, Grid, Origin, TILE_SIZE, TILE_WIDTH, Tiles};
|
||||
use crate::{Currency, Progressable};
|
||||
use servicepoint::{GridMut};
|
||||
use std::time::Duration;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
|
|
@ -8,18 +7,14 @@ pub struct Bar {
|
|||
progress: f64,
|
||||
speed: f64,
|
||||
factor: f64,
|
||||
origin: Origin<Tiles>,
|
||||
width_tiles: usize,
|
||||
}
|
||||
|
||||
impl Bar {
|
||||
pub(crate) fn new(factor: f64, origin: Origin<Tiles>) -> Self {
|
||||
pub(crate) fn new(factor: f64, speed: f64) -> Self {
|
||||
Self {
|
||||
factor,
|
||||
progress: 0f64,
|
||||
speed: 0f64,
|
||||
origin,
|
||||
width_tiles: TILE_WIDTH / 2, // TODO: param
|
||||
speed,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -47,9 +42,9 @@ impl Progressable for Bar {
|
|||
}
|
||||
}
|
||||
|
||||
impl GenerateCommands for Bar {
|
||||
fn generate_commands(&self, q: &mut impl PacketQueue) {
|
||||
let mut bitmap = Bitmap::new(self.width_tiles * TILE_SIZE, TILE_SIZE).unwrap();
|
||||
impl Bar {
|
||||
pub fn draw<P: GridMut<bool>>(&self, bitmap: &mut P) {
|
||||
bitmap.fill(false);
|
||||
|
||||
let margin = 1;
|
||||
let bar_height = bitmap.height() - 2 * margin;
|
||||
|
|
@ -77,13 +72,5 @@ impl GenerateCommands for Bar {
|
|||
bitmap.set(x, y, (x + y) % 2 == 0);
|
||||
}
|
||||
}
|
||||
|
||||
// to command
|
||||
q.enqueue_command(BitmapCommand {
|
||||
bitmap,
|
||||
origin: Origin::from(&self.origin),
|
||||
compression: Default::default(),
|
||||
})
|
||||
.unwrap();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue