MCPcopy Create free account
hub / github.com/asmuth/clip / plot_grid

Function plot_grid

src/plot/grid.cc:47–87  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

45};
46
47ReturnCode 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
89ReturnCode plot_grid(Context* ctx, PlotConfig* plot, const Expr* expr) {
90 /* set defaults from ctxironment */

Callers

nothing calls this directly

Calls 10

layer_get_dpiFunction · 0.85
layer_get_font_sizeFunction · 0.85
measure_normalizeFunction · 0.85
plot_get_clipFunction · 0.85
layer_getFunction · 0.85
format_noopFunction · 0.85
draw_lineFunction · 0.85
from_ptFunction · 0.85
expr_walk_map_wrappedFunction · 0.85

Tested by

no test coverage detected