From b593a29e9c122fa7912fec6074fd2259c2936be5 Mon Sep 17 00:00:00 2001 From: ClementTsang Date: Sat, 8 Feb 2020 18:00:50 -0500 Subject: [PATCH] More cleaning up of new colour feature --- src/canvas.rs | 188 +-------------------- src/canvas/canvas_colours.rs | 119 +++++++++++++ src/canvas/canvas_colours/drawing_utils.rs | 73 ++++++++ 3 files changed, 195 insertions(+), 185 deletions(-) create mode 100644 src/canvas/canvas_colours.rs create mode 100644 src/canvas/canvas_colours/drawing_utils.rs diff --git a/src/canvas.rs b/src/canvas.rs index 9eaa29f9..c70ae720 100644 --- a/src/canvas.rs +++ b/src/canvas.rs @@ -2,7 +2,7 @@ use crate::{ app::{self, data_harvester::processes::ProcessHarvest}, constants::*, data_conversion::{ConvertedCpuData, ConvertedProcessData}, - utils::{error, gen_util::*}, + utils::error, }; use std::cmp::max; use std::collections::HashMap; @@ -15,10 +15,8 @@ use tui::{ Terminal, }; -const STANDARD_FIRST_COLOUR: Color = Color::Rgb(150, 106, 253); -const STANDARD_SECOND_COLOUR: Color = Color::LightYellow; -const GOLDEN_RATIO: f32 = 0.618_034; // Approx, good enough for use (also Clippy gets mad if it's too long) - +mod canvas_colours; +use canvas_colours::*; // Headers const CPU_LEGEND_HEADER: [&str; 2] = ["CPU", "Use%"]; const DISK_HEADERS: [&str; 7] = ["Disk", "Mount", "Used", "Free", "Total", "R/s", "W/s"]; @@ -101,75 +99,6 @@ pub struct DisplayableData { pub cpu_data: Vec, } -/// Generates random colours. Strategy found from -/// https://martin.ankerl.com/2009/12/09/how-to-create-random-colors-programmatically/ -fn gen_n_styles(num_to_gen: i32) -> Vec