MCPcopy Create free account
hub / github.com/JakkuSakura/plotters-gpui / plot

Method plot

examples/mandelbrot.rs:69–105  ·  view source on GitHub ↗
(
        &mut self,
        root: &DrawingArea<GpuiBackend, Shift>,
    )

Source from the content-addressed store, hash-verified

67struct MyChart;
68impl PlottersChart for MyChart {
69 fn plot(
70 &mut self,
71 root: &DrawingArea<GpuiBackend, Shift>,
72 ) -> Result<(), plotters_gpui::DrawingErrorKind> {
73 let mut chart = ChartBuilder::on(root)
74 .margin(20)
75 .x_label_area_size(10)
76 .y_label_area_size(10)
77 .build_cartesian_2d(-2.1f64..0.6f64, -1.2f64..1.2f64)
78 .unwrap();
79
80 chart
81 .configure_mesh()
82 .disable_x_mesh()
83 .disable_y_mesh()
84 .draw()
85 .unwrap();
86
87 let plotting_area = chart.plotting_area();
88
89 let range = plotting_area.get_pixel_range();
90
91 let (pw, ph) = (range.0.end - range.0.start, range.1.end - range.1.start);
92 let (xr, yr) = (chart.x_range(), chart.y_range());
93
94 for (x, y, c) in mandelbrot_set(xr, yr, (pw as usize, ph as usize), 100) {
95 if c != 100 {
96 plotting_area
97 .draw_pixel((x, y), &MandelbrotHSL::get_color(c as f64 / 100.0))
98 .unwrap();
99 } else {
100 plotting_area.draw_pixel((x, y), &BLACK).unwrap();
101 }
102 }
103
104 Ok(())
105 }
106}
107
108fn main_viewer(cx: &mut App) -> MainViewer {

Callers

nothing calls this directly

Calls 2

mandelbrot_setFunction · 0.85
draw_pixelMethod · 0.80

Tested by

no test coverage detected