From 16231f31b36163c69cf2fe76a29c68bda52b7043 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Chodzikiewicz?= Date: Tue, 2 Mar 2021 21:19:26 +0100 Subject: [PATCH] Remove polyplot --- examples/polyplot_mono.rs | 50 --------------------------------------- examples/polyplot_rgb.rs | 49 -------------------------------------- src/lib.rs | 1 - src/polyplot.rs | 38 ----------------------------- 4 files changed, 138 deletions(-) delete mode 100644 examples/polyplot_mono.rs delete mode 100644 examples/polyplot_rgb.rs delete mode 100644 src/polyplot.rs diff --git a/examples/polyplot_mono.rs b/examples/polyplot_mono.rs deleted file mode 100644 index d767a12..0000000 --- a/examples/polyplot_mono.rs +++ /dev/null @@ -1,50 +0,0 @@ -use embedded_graphics::{ - pixelcolor::BinaryColor, - prelude::*, -}; - -use embedded_graphics_simulator::{ - SimulatorDisplay, - Window, - OutputSettingsBuilder, - BinaryColorTheme -}; - -use embedded_plots::{ - polyplot::{PolyPlot}, - curve::{PlotPoint, Curve}, -}; - -fn main() -> Result<(), core::convert::Infallible> { - let mut display: SimulatorDisplay = SimulatorDisplay::new(Size::new(128, 48)); - - let data1 = vec![ - PlotPoint { x: 0, y: 0 }, - PlotPoint { x: 1, y: 1 }, - PlotPoint { x: 2, y: 1 }, - PlotPoint { x: 3, y: 0 }, - ]; - - let data2 = vec![ - PlotPoint { x: 0, y: 1 }, - PlotPoint { x: 1, y: 0 }, - PlotPoint { x: 2, y: 3 }, - PlotPoint { x: 3, y: 2 }, - PlotPoint { x: 4, y: 2 }, - ]; - - let curves = vec![ - (Curve::from_data(data1.as_slice()), BinaryColor::On), - (Curve::from_data(data2.as_slice()), BinaryColor::On), - ]; - - let plot = PolyPlot::new(curves.as_slice(), Point { x: 10, y: 3 }, Point { x: 120, y: 45 }); - - plot.draw(&mut display)?; - let output_settings = OutputSettingsBuilder::new() - .theme(BinaryColorTheme::OledBlue) - .build(); - Window::new("Basic plot", &output_settings).show_static(&display); - - Ok(()) -} \ No newline at end of file diff --git a/examples/polyplot_rgb.rs b/examples/polyplot_rgb.rs deleted file mode 100644 index 056e3d5..0000000 --- a/examples/polyplot_rgb.rs +++ /dev/null @@ -1,49 +0,0 @@ -use embedded_graphics::{ - pixelcolor::Rgb565, - prelude::*, -}; - -use embedded_graphics_simulator::{ - SimulatorDisplay, - Window, - OutputSettingsBuilder, - -}; - -use embedded_plots::{ - polyplot::{PolyPlot}, - curve::{PlotPoint, Curve}, -}; - -fn main() -> Result<(), core::convert::Infallible> { - let mut display: SimulatorDisplay = SimulatorDisplay::new(Size::new(480, 272)); - - let data1 = vec![ - PlotPoint { x: 0, y: 0 }, - PlotPoint { x: 1, y: 1 }, - PlotPoint { x: 2, y: 1 }, - PlotPoint { x: 3, y: 0 }, - ]; - - let data2 = vec![ - PlotPoint { x: 0, y: 1 }, - PlotPoint { x: 1, y: 0 }, - PlotPoint { x: 2, y: 3 }, - PlotPoint { x: 3, y: 2 }, - PlotPoint { x: 4, y: 2 }, - ]; - - let curves = vec![ - (Curve::from_data(data1.as_slice()), RgbColor::YELLOW), - (Curve::from_data(data2.as_slice()), RgbColor::RED), - ]; - - let plot = PolyPlot::new(curves.as_slice(), Point { x: 10, y: 10 }, Point { x: 470, y: 260 }); - - plot.draw(&mut display)?; - let output_settings = OutputSettingsBuilder::new() - .build(); - Window::new("Basic plot", &output_settings).show_static(&display); - - Ok(()) -} \ No newline at end of file diff --git a/src/lib.rs b/src/lib.rs index 3b7e2e2..7b2b50c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -2,7 +2,6 @@ pub mod curve; pub mod axis; -pub mod polyplot; pub mod single_plot; mod range_conv; \ No newline at end of file diff --git a/src/polyplot.rs b/src/polyplot.rs deleted file mode 100644 index 279d1c7..0000000 --- a/src/polyplot.rs +++ /dev/null @@ -1,38 +0,0 @@ -use crate::curve::Curve; -use embedded_graphics::drawable::Drawable; -use embedded_graphics::DrawTarget; -use embedded_graphics::prelude::Point; -use embedded_graphics::pixelcolor::PixelColor; - -pub struct PolyPlot<'a, C> -{ - curves: &'a [(Curve<'a>, C)], - top_left: Point, - bottom_right: Point, -} - -impl<'a, C> PolyPlot<'a, C> - where - C: PixelColor -{ - pub fn new(curves: &'a [(Curve<'a>, C)], top_left: Point, bottom_right: Point) -> PolyPlot { - PolyPlot { curves, top_left, bottom_right } - } -} - -impl<'a, C> Drawable for PolyPlot<'a, C> - where - C: PixelColor + Default, -{ - fn draw>(self, display: &mut D) -> Result<(), D::Error> { - for (curve, color) in self.curves { - curve.into_drawable_curve( - &self.top_left, - &self.bottom_right, - ).set_color(*color) - .set_thickness(2) - .draw(display)?; - } - Ok(()) - } -} \ No newline at end of file