custom function colors
This commit is contained in:
parent
5d71c82c0d
commit
6041da764b
@ -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,
|
||||
];
|
||||
|
||||
@ -327,7 +327,9 @@ impl FunctionEntry {
|
||||
|
||||
/// Displays the function's output on PlotUI `plot_ui` with settings
|
||||
/// `settings`. Returns an `Option<f64>` of the calculated integral
|
||||
pub fn display(&self, plot_ui: &mut PlotUi, settings: &AppSettings) -> Option<f64> {
|
||||
pub fn display(
|
||||
&self, plot_ui: &mut PlotUi, settings: &AppSettings, main_plot_color: Color32,
|
||||
) -> Option<f64> {
|
||||
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()),
|
||||
);
|
||||
}
|
||||
|
||||
@ -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();
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user