| 45 | }; |
| 46 | |
| 47 | ReturnCode plot_grid( |
| 48 | Context* ctx, |
| 49 | PlotConfig* plot, |
| 50 | std::shared_ptr<GridlineDefinition> config) { |
| 51 | MeasureConv conv; |
| 52 | conv.dpi = layer_get_dpi(ctx); |
| 53 | conv.font_size = layer_get_font_size(ctx); |
| 54 | conv.parent_size = layer_get_font_size(ctx); |
| 55 | |
| 56 | measure_normalize(conv, &config->stroke_style.line_width); |
| 57 | |
| 58 | const auto& bbox = plot_get_clip(plot, layer_get(ctx)); |
| 59 | |
| 60 | ScaleLayout slayout_x; |
| 61 | config->layout_x(config->scale_x, format_noop(), &slayout_x); |
| 62 | |
| 63 | ScaleLayout slayout_y; |
| 64 | config->layout_y(config->scale_y, format_noop(), &slayout_y); |
| 65 | |
| 66 | for (const auto& tick : slayout_x.positions) { |
| 67 | auto line_x = bbox.x + bbox.w * tick; |
| 68 | |
| 69 | draw_line( |
| 70 | ctx, |
| 71 | Point(line_x, bbox.y), |
| 72 | Point(line_x, bbox.y + bbox.h), |
| 73 | config->stroke_style); |
| 74 | } |
| 75 | |
| 76 | for (const auto& tick : slayout_y.positions) { |
| 77 | auto line_y = bbox.y + bbox.h * (1.0 - tick); |
| 78 | |
| 79 | draw_line( |
| 80 | ctx, |
| 81 | Point(bbox.x, line_y), |
| 82 | Point(bbox.x + bbox.w, line_y), |
| 83 | config->stroke_style); |
| 84 | } |
| 85 | |
| 86 | return OK; |
| 87 | } |
| 88 | |
| 89 | ReturnCode plot_grid(Context* ctx, PlotConfig* plot, const Expr* expr) { |
| 90 | /* set defaults from ctxironment */ |
nothing calls this directly
no test coverage detected