This commit is contained in:
Simon Gardling
2022-02-28 12:06:54 -05:00
parent e16d35ed62
commit 92bc183dbd
2 changed files with 10 additions and 12 deletions

View File

@@ -163,7 +163,7 @@ impl Function {
self.max_x = max_x;
self.pixel_width = pixel_width;
} else if ((min_x != self.min_x) | (max_x != self.max_x)) && self.back_cache.is_some() {
// debug_log("back_cache: partial regen");
debug_log("back_cache: partial regen");
let range_new: f64 = max_x.abs() + min_x.abs();
let resolution: f64 = (self.pixel_width as f64 / range_new) as f64;
@@ -209,11 +209,11 @@ impl Function {
pub fn run(&mut self) -> FunctionOutput {
let back_values: Vec<Value> = match self.back_cache.is_some() {
true => {
// debug_log("back_cache: using");
debug_log("back_cache: using");
self.back_cache.as_ref().expect("").clone()
}
false => {
// debug_log("back_cache: regen");
debug_log("back_cache: regen");
let absrange = (self.max_x - self.min_x).abs();
let resolution: f64 = (self.pixel_width as f64 / absrange) as f64;
let back_data: Vec<Value> = (1..=self.pixel_width)
@@ -231,13 +231,13 @@ impl Function {
if self.integral {
let front_bars: (Vec<Bar>, f64) = match self.front_cache.is_some() {
true => {
// debug_log("front_cache: using");
debug_log("front_cache: using");
let cache = self.front_cache.as_ref().expect("");
let vec_bars: Vec<Bar> = cache.0.to_vec();
(vec_bars, cache.1)
}
false => {
// debug_log("front_cache: regen");
debug_log("front_cache: regen");
let (data, area) = self.integral_rectangles();
let bars: Vec<Bar> = data.iter().map(|(x, y)| Bar::new(*x, *y)).collect();