MCPcopy Create free account
hub / github.com/donkeyteethUX/iced_plot / draw_grid

Function draw_grid

src/plot_renderer/canvas.rs:79–115  ·  view source on GitHub ↗
(frame: &mut Frame, state: &PlotState, bounds: Rectangle)

Source from the content-addressed store, hash-verified

77}
78
79fn draw_grid(frame: &mut Frame, state: &PlotState, bounds: Rectangle) {
80 for tick in &state.x_ticks {
81 let color = match tick.tick.line_type {
82 TickWeight::Major => state.grid_style.major,
83 TickWeight::Minor => state.grid_style.minor,
84 TickWeight::SubMinor => state.grid_style.sub_minor,
85 };
86 let line = canvas::Path::line(
87 iced::Point::new(tick.screen_pos, 0.0),
88 iced::Point::new(tick.screen_pos, bounds.height),
89 );
90 frame.stroke(
91 &line,
92 canvas::Stroke::default()
93 .with_width(GRID_STROKE_WIDTH)
94 .with_color(color),
95 );
96 }
97
98 for tick in &state.y_ticks {
99 let color = match tick.tick.line_type {
100 TickWeight::Major => state.grid_style.major,
101 TickWeight::Minor => state.grid_style.minor,
102 TickWeight::SubMinor => state.grid_style.sub_minor,
103 };
104 let line = canvas::Path::line(
105 iced::Point::new(0.0, tick.screen_pos),
106 iced::Point::new(bounds.width, tick.screen_pos),
107 );
108 frame.stroke(
109 &line,
110 canvas::Stroke::default()
111 .with_width(GRID_STROKE_WIDTH)
112 .with_color(color),
113 );
114 }
115}
116
117fn draw_fills(frame: &mut Frame, state: &PlotState, bounds: Rectangle) {
118 for fill in state.fills.iter() {

Callers 1

drawFunction · 0.85

Calls 3

newFunction · 0.50
with_colorMethod · 0.45
with_widthMethod · 0.45

Tested by

no test coverage detected