Skip to content

Commit

Permalink
piston: Can only support 1 figure
Browse files Browse the repository at this point in the history
  • Loading branch information
malikolivier committed Mar 12, 2018
1 parent d0f557b commit 9a7f6ed
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion piston_backend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ impl matplotrs_backend::Backend for PistonBackend {
}

fn new_figure(&mut self, title: &str, size: &(f64, f64)) -> Result<(), Self::Err> {
if self.figures.len() > 0 {
return Err(From::from("Only one figure is currently supported on piston backend! See https://github.com/PistonDevelopers/piston-examples/issues/401".to_owned()))
}
let &(x, y) = size;
let window = WindowSettings::new(
title,
Expand Down Expand Up @@ -100,8 +103,8 @@ impl matplotrs_backend::Backend for PistonBackend {
}

fn show(mut self) -> Result<i32, Self::Err> {
let mut events = Events::new(EventSettings::new());
for figure in self.figures.iter_mut() {
let mut events = Events::new(EventSettings::new());
while let Some(e) = events.next(&mut figure.w) {
if let Some(r) = e.render_args() {
figure.render(&r);
Expand All @@ -112,6 +115,7 @@ impl matplotrs_backend::Backend for PistonBackend {
}
}
}
println!("Bye!");
Ok(0)
}
}
Expand Down

0 comments on commit 9a7f6ed

Please sign in to comment.