(bar: Bar, step_y: f64, y_half_font: f32, y_font_size: f32, max_y: f64, ys: Vec<f64>)
| 57 | } |
| 58 | |
| 59 | pub async fn negative_only(bar: Bar, step_y: f64, y_half_font: f32, y_font_size: f32, max_y: f64, ys: Vec<f64>) { |
| 60 | loop { |
| 61 | clear_background(WHITE); |
| 62 | |
| 63 | for (idx, char) in bar.axis_desc.y_label.chars().into_iter().enumerate() { |
| 64 | draw_text_rot(&char.to_string(), 7., screen_height() / 2. - (YLABEL_SIZE / 2. * idx as f32) , YLABEL_SIZE, BLACK, -std::f32::consts::PI / 2.,); |
| 65 | } |
| 66 | |
| 67 | draw_text(&bar.axis_desc.title, screen_width() / 2., DISTANCE_X_AXIS / 3. + 7., TITLE_SIZE, BLACK); |
| 68 | draw_text(&bar.axis_desc.x_label, screen_width() / 2., screen_height() - DISTANCE_X_AXIS / 3., YLABEL_SIZE, BLACK); |
| 69 | |
| 70 | // x axis |
| 71 | draw_line(0., DISTANCE_X_AXIS, screen_width(), DISTANCE_X_AXIS, COORD_THICKNESS, GRAY); |
| 72 | |
| 73 | // y axis |
| 74 | draw_line(DISTANCE, 0., DISTANCE, screen_height(), COORD_THICKNESS, GRAY); |
| 75 | |
| 76 | if step_y > 1. { |
| 77 | for (idx, val) in (step_y as i128..=max_y as i128) |
| 78 | .step_by(step_y as usize) |
| 79 | .enumerate() |
| 80 | { |
| 81 | let y = DISTANCE_X_AXIS + bar.desc.spacing_y * idx as f32 + bar.desc.spacing_y; |
| 82 | draw_line_with_text(y, -val, y_half_font, y_font_size).await; |
| 83 | } |
| 84 | } else { |
| 85 | let tens_step = count_inv_tens(step_y); |
| 86 | |
| 87 | let max_y = max_y * tens_step as f64; |
| 88 | let step_y = step_y * tens_step as f64; |
| 89 | |
| 90 | for (idx, val) in (step_y as i128..=max_y as i128) |
| 91 | .step_by(step_y as usize) |
| 92 | .enumerate() |
| 93 | { |
| 94 | let y = (screen_height() / 2.) + bar.desc.spacing_y * idx as f32 + bar.desc.spacing_y; |
| 95 | draw_line_with_text(y, -val as f64 / tens_step as f64, y_half_font, y_font_size).await; |
| 96 | } |
| 97 | } |
| 98 | |
| 99 | if is_key_pressed(KeyCode::Escape) { |
| 100 | break; |
| 101 | } |
| 102 | draw_bars(DISTANCE_X_AXIS, &ys, &bar).await; |
| 103 | next_frame().await; |
| 104 | std::thread::sleep(std::time::Duration::from_millis(16)); |
| 105 | } |
| 106 | } |
| 107 | |
| 108 | pub async fn positive_negative(bar: Bar, step_y: f64, y_half_font: f32, y_font_size: f32, max_y: f64, ys: Vec<f64>) { |
| 109 | loop { |
no test coverage detected