feat(plot): vertical y-axis label via a rotated text run

This commit is contained in:
Martino Ferrari committed 2026-09-28 11:14:36 +02:00
1 parent 1cb5970757
commit daeb31b1ea
6 files changed
+453 -80

No files matched your search

+16 -9
View File
@@ -261,15 +261,22 @@ class Renderer {
/// Lays one run of text out at a framebuffer position and stages it, shifting
/// it into viewport space. Returns the pen past the run.
Vec2 stage_text(Vec2 pos_px, const char* utf8);
/// Width of the longest prefix of `utf8` that fits `budget_px`, at the size the
/// text pipeline draws with: exactly what `stage_text_clipped()` stages.
f32 clipped_text_width(const char* utf8, f32 budget_px) const;
/// Stages as much of `utf8` as fits `budget_px` at `pos_px` and returns the
/// width it staged. Titles are the runs that need this: a title longer than the
/// strip the layout reserved for it is cut there, rather than being allowed to
/// grow the strip (which would shrink the plot) or to spill over the tick labels
/// and the data (which is the defect the strips exist to prevent).
f32 stage_text_clipped(Vec2 pos_px, const char* utf8, f32 budget_px);
/// Width of the longest prefix of `utf8` that fits `budget_px` along `axis`, at
/// the size the text pipeline draws with: exactly what `stage_text_clipped()`
/// stages.
f32 clipped_text_width(const char* utf8, f32 budget_px, Vec2 axis) const;
/// Stages as much of `utf8` as fits `budget_px` along `axis` at `pos_px` and
/// returns the length it staged. Titles are the runs that need this: a title
/// longer than the strip the layout reserved for it is cut there, rather than
/// being allowed to grow the strip (which would shrink the plot) or to spill
/// over the tick labels and the data (which is the defect the strips exist to
/// prevent).
///
/// `axis` is the run's own direction and a unit vector: (1, 0) for the
/// horizontal x title, which spends the strip's width, and (0,-1) for the y
/// title, which reads bottom-to-top and spends the strip's height. `pos_px` is
/// the pen -- for the rotated run, the bottom-left corner of its first cell.
f32 stage_text_clipped(Vec2 pos_px, const char* utf8, f32 budget_px, Vec2 axis);
void draw_grid(const Plot& plot);
void draw_axis_lines(const Plot& plot);