diff --git a/src/consts.rs b/src/consts.rs index 10e5a20..5fecadb 100644 --- a/src/consts.rs +++ b/src/consts.rs @@ -2,6 +2,7 @@ use crate::function::Riemann; use std::ops::RangeInclusive; use const_format::formatc; +use eframe::epaint::Color32; use shadow_rs::shadow; shadow!(build); @@ -46,3 +47,24 @@ const_assert!(DEFAULT_MAX_X > DEFAULT_MIN_X); /// Default number of integral boxes pub const DEFAULT_INTEGRAL_NUM: usize = 100; + +pub const COLORS: &'static [Color32; 14] = &[ + Color32::RED, + // Color32::GREEN, + // Color32::YELLOW, + // Color32::BLUE, + Color32::BROWN, + Color32::GOLD, + Color32::GRAY, + Color32::WHITE, + Color32::LIGHT_YELLOW, + Color32::LIGHT_GREEN, + // Color32::LIGHT_BLUE, + Color32::LIGHT_GRAY, + Color32::LIGHT_RED, + Color32::DARK_GRAY, + Color32::DARK_RED, + Color32::KHAKI, + Color32::DARK_GREEN, + Color32::DARK_BLUE, +]; diff --git a/src/function.rs b/src/function.rs index 2b411a3..f3485cb 100644 --- a/src/function.rs +++ b/src/function.rs @@ -327,7 +327,9 @@ impl FunctionEntry { /// Displays the function's output on PlotUI `plot_ui` with settings /// `settings`. Returns an `Option` of the calculated integral - pub fn display(&self, plot_ui: &mut PlotUi, settings: &AppSettings) -> Option { + pub fn display( + &self, plot_ui: &mut PlotUi, settings: &AppSettings, main_plot_color: Color32, + ) -> Option { if self.test_result.is_some() { return None; } @@ -341,7 +343,7 @@ impl FunctionEntry { back_data .clone() .to_line() - .color(Color32::RED) + .color(main_plot_color) .name(self.get_func_raw()), ); } diff --git a/src/math_app.rs b/src/math_app.rs index 199131d..21064e7 100644 --- a/src/math_app.rs +++ b/src/math_app.rs @@ -593,7 +593,7 @@ impl epi::App for MathApp { // Button to add a new function if ui - .add(Button::new("Add Function")) + .add_enabled(14 > self.func_strs.len(), Button::new("Add Function")) .on_hover_text("Create and graph new function") .clicked() { @@ -755,7 +755,7 @@ impl epi::App for MathApp { .functions .iter() .enumerate() - .map(|(_, function)| function.display(plot_ui, &self.settings)) + .map(|(i, function)| function.display(plot_ui, &self.settings, COLORS[i])) .collect(); }); });