Skip to content

Commit

Permalink
writing codes for effect
Browse files Browse the repository at this point in the history
  • Loading branch information
lemolatoon committed Sep 25, 2021
1 parent e71fd0e commit 9b7bddd
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,22 +153,30 @@ impl Lienzo {
}

fn effect_init_place(&mut self, now: chrono::DateTime<chrono::Local>) {
self.erased_lines = self.grid.next.place(&mut self.grid.colors);
// 消す予定のライン
self.erased_lines = self.grid.next.erase_lines(&mut self.grid.colors);

if !self.erased_lines.is_empty() {
//init
self.now_erase = now;
self.erase_flag = true;
// TODO: call fn here : write effect in grid.rs
// the fn is also not implemented
self.effect_check(now);
} else {
// どこも消さないなら単に置くだけ
self.grid.next._place(&mut self.grid.colors);
}
}

fn effect_check(&mut self, now: chrono::DateTime<chrono::Local>) {
// erase が確定したときに呼ばれる
// つまり、place_check内部からも呼ばれる
if now.timestamp_millis() - self.now_erase.timestamp_millis() > Self::LINES_ERASE_DELTA {
// effect終了
self.erase_flag = false;
self.erased_lines = Vec::new();
// TODO: clear the Vector in grid which is for effect
} else {
self.grid.effect_lines(&self.erased_lines, 8); // 8 is black
}
Expand Down Expand Up @@ -237,6 +245,7 @@ impl Application for Lienzo {
now_erase: chrono::Local::now(),
erase_flag: false,
erased_lines: Vec::new(),
buffered_lines: Vec::new(),
},
Command::none(),
)
Expand Down

0 comments on commit 9b7bddd

Please sign in to comment.