Added both the build() and the begin()+end() options for Plot
- Copied the trick from imgui-rs to notice if a begin() is left unmatched - Changed plot_line to be a struct, but might go away from that again. Initial idea was to add things like setting markers and colors to this as struct methods, but it seems this will lead to lots of code overhead compared to the pushing and popping stylevars approach taken in the C++ implementation.
This commit is contained in:
parent
b832924fad
commit
a747fa2d91
2 changed files with 80 additions and 30 deletions
|
@ -1,5 +1,5 @@
|
|||
use imgui::*;
|
||||
use implot;
|
||||
use implot::{Plot, PlotLine};
|
||||
|
||||
mod support;
|
||||
|
||||
|
@ -21,17 +21,17 @@ fn main() {
|
|||
ui.checkbox(im_str!("Show demo"), &mut showing_demo);
|
||||
|
||||
// Draw a plot
|
||||
implot::Plot::new("Demo plot")
|
||||
Plot::new("Demo plot")
|
||||
.size(400.0, 300.0)
|
||||
.x_label("awesome x label")
|
||||
.y_label("awesome y label")
|
||||
.build(|| {
|
||||
implot::plot_line(&vec![2.0, 2.0], &vec![2.0, 1.0], "Left eye");
|
||||
implot::plot_line(&vec![4.0, 4.0], &vec![2.0, 1.0], "Right eye");
|
||||
PlotLine::new("Left eye").plot(&vec![2.0, 2.0], &vec![2.0, 1.0]);
|
||||
PlotLine::new("Right eye").plot(&vec![4.0, 4.0], &vec![2.0, 1.0]);
|
||||
|
||||
let x_values = vec![1.0, 2.0, 4.0, 5.0];
|
||||
let y_values = vec![1.0, 0.0, 0.0, 1.0];
|
||||
implot::plot_line(&x_values, &y_values, "Mouth");
|
||||
PlotLine::new("Mouth").plot(&x_values, &y_values);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue