MCPcopy Create free account
hub / github.com/elftausend/graplot / run

Function run

src/render/plot.rs:12–285  ·  view source on GitHub ↗
(plot: Plot, min_y: f64, other_scaling: bool)

Source from the content-addressed store, hash-verified

10pub const COORD_DARKGRAY: Color = Color::new(0.31, 0.31, 0.31, ALPHA);
11
12pub async fn run(plot: Plot, min_y: f64, other_scaling: bool) {
13 let mut spacing_x = plot.desc.spacing_x;
14 let mut spacing_y = plot.desc.spacing_y;
15
16 let max_x = match plot.desc.end_x {
17 Some(x) => x.0,
18 None => max_display(max_matrix(&plot.xs), other_scaling),
19 };
20
21 //let mut max_x = max(&maxed);
22 let x_font_size = get_font_size_x(max_x);
23
24 let steps = get_steps(max_x, plot.desc.min_steps_x.into());
25 let step_x = max_x / steps;
26
27 let start_x = step_x;
28
29 //let maxed = plot.ys.iter().map(|y| y.abs()).collect::<Vec<f64>>();
30 //let mut max_y = max(&maxed);
31
32 let mut max_y = max_matrix(&plot.ys);
33 max_y = max_display(max_y, other_scaling);
34
35 let y_font_size = get_font_size_y(max_y);
36
37 let steps_y = get_steps(max_y, plot.desc.min_steps_y.into());
38 let step_y = (max_y) / steps_y;
39
40 let start_y = if min_y > 0. { min_y } else { step_y };
41 //let start_y = step_y;
42
43 loop {
44 let (_, wheel_y) = mouse_wheel();
45
46 if is_key_down(KeyCode::LeftShift) || is_key_down(KeyCode::RightShift) {
47 spacing_y += wheel_y * 0.2;
48 } else {
49 spacing_x += wheel_y * 0.2;
50 }
51
52 clear_background(WHITE);
53
54 let half_height = screen_height() / 2.;
55 let half_width = screen_width() / 2.;
56
57 if !plot.axis_desc.title.is_empty() {
58 let len = plot.axis_desc.title.len() as f32 * (TITLE_SIZE / 4. - COORD_THICKNESS / 2.);
59 draw_text(
60 &plot.axis_desc.title,
61 half_width - len,
62 half_height - spacing_y * steps_y as f32 - 50.,
63 TITLE_SIZE,
64 BLACK,
65 );
66 }
67
68 if !plot.axis_desc.y_label.is_empty() {
69 let len =

Callers

nothing calls this directly

Calls 10

max_displayFunction · 0.85
max_matrixFunction · 0.85
get_font_size_xFunction · 0.85
get_stepsFunction · 0.85
get_font_size_yFunction · 0.85
divsFunction · 0.85
subFunction · 0.85
axis_desc_yFunction · 0.85
count_inv_tensFunction · 0.85
axis_desc_xFunction · 0.85

Tested by

no test coverage detected