rustfmt
This commit is contained in:
parent
c09c2d9beb
commit
b28a652aef
@ -1,6 +1,5 @@
|
|||||||
use crate::misc::{add_asterisks, Function};
|
use crate::misc::{add_asterisks, Function};
|
||||||
|
|
||||||
|
|
||||||
pub enum UpdateType {
|
pub enum UpdateType {
|
||||||
FULL,
|
FULL,
|
||||||
FRONT,
|
FRONT,
|
||||||
@ -34,9 +33,9 @@ impl ChartManager {
|
|||||||
pub fn draw_back(&mut self) -> Vec<(f64, f64)> {
|
pub fn draw_back(&mut self) -> Vec<(f64, f64)> {
|
||||||
let absrange = (self.max_x - self.min_x).abs();
|
let absrange = (self.max_x - self.min_x).abs();
|
||||||
let output: Vec<(f64, f64)> = (1..=self.resolution)
|
let output: Vec<(f64, f64)> = (1..=self.resolution)
|
||||||
.map(|x| ((x as f64 / self.resolution as f64) * absrange) + self.min_x)
|
.map(|x| ((x as f64 / self.resolution as f64) * absrange) + self.min_x)
|
||||||
.map(|x| (x, self.function.run(x)))
|
.map(|x| (x, self.function.run(x)))
|
||||||
.collect();
|
.collect();
|
||||||
output
|
output
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,7 +56,8 @@ impl ChartManager {
|
|||||||
let update_func: bool = !self.function.str_compare(func_str.clone());
|
let update_func: bool = !self.function.str_compare(func_str.clone());
|
||||||
|
|
||||||
let update_back = update_func | (min_x != self.min_x) | (max_x != self.max_x);
|
let update_back = update_func | (min_x != self.min_x) | (max_x != self.max_x);
|
||||||
let update_front = update_back | (self.resolution != resolution) | (num_interval != self.num_interval);
|
let update_front =
|
||||||
|
update_back | (self.resolution != resolution) | (num_interval != self.num_interval);
|
||||||
|
|
||||||
if update_func {
|
if update_func {
|
||||||
self.function = Function::from_string(func_str);
|
self.function = Function::from_string(func_str);
|
||||||
|
|||||||
@ -13,7 +13,7 @@ pub struct MathApp {
|
|||||||
resolution: usize,
|
resolution: usize,
|
||||||
chart_manager: ChartManager,
|
chart_manager: ChartManager,
|
||||||
back_cache: Cache<Vec<Value>>,
|
back_cache: Cache<Vec<Value>>,
|
||||||
front_cache: Cache<(Vec<Bar>, f64)>
|
front_cache: Cache<(Vec<Bar>, f64)>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for MathApp {
|
impl Default for MathApp {
|
||||||
@ -68,7 +68,6 @@ impl MathApp {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
impl epi::App for MathApp {
|
impl epi::App for MathApp {
|
||||||
fn name(&self) -> &str { "Integral Demonstration" }
|
fn name(&self) -> &str { "Integral Demonstration" }
|
||||||
|
|
||||||
@ -138,19 +137,14 @@ impl epi::App for MathApp {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
let do_update = chart_manager.update(
|
let do_update =
|
||||||
func_str.clone(),
|
chart_manager.update(func_str.clone(), *min_x, *max_x, *num_interval, *resolution);
|
||||||
*min_x,
|
|
||||||
*max_x,
|
|
||||||
*num_interval,
|
|
||||||
*resolution,
|
|
||||||
);
|
|
||||||
|
|
||||||
match do_update {
|
match do_update {
|
||||||
UpdateType::FULL => {
|
UpdateType::FULL => {
|
||||||
back_cache.invalidate();
|
back_cache.invalidate();
|
||||||
front_cache.invalidate();
|
front_cache.invalidate();
|
||||||
},
|
}
|
||||||
UpdateType::BACK => back_cache.invalidate(),
|
UpdateType::BACK => back_cache.invalidate(),
|
||||||
UpdateType::FRONT => front_cache.invalidate(),
|
UpdateType::FRONT => front_cache.invalidate(),
|
||||||
_ => {}
|
_ => {}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user