ogl_beamforming

Ultrasound Beamforming Implemented with OpenGL
git clone anongit@rnpnr.xyz:ogl_beamforming.git
Log | Files | Refs | Feed | Submodules | LICENSE

Commit: 1fb13ea17746211c6d4ee1afd0e1bad8e628b314
Parent: 41ae3fe3e901a8fb1ae3be7c5e118a48e7ec65d4
Author: Randy Palamar
Date:   Fri, 14 Mar 2025 06:48:07 -0600

ui: add a helper for drawing outlined text

Diffstat:
Mui.c | 19++++++++++++++++---
1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/ui.c b/ui.c @@ -474,6 +474,20 @@ draw_text(Font font, s8 text, v2 pos, Color colour) return result; } +/* NOTE(rnp): expensive but of the available options in raylib this gives the best results */ +static v2 +draw_outlined_text(Font font, s8 text, v2 pos, f32 outline_width, Color colour, Color outline) +{ + draw_text(font, text, sub_v2(pos, (v2){.x = outline_width, .y = outline_width}), outline); + draw_text(font, text, sub_v2(pos, (v2){.x = outline_width, .y = -outline_width}), outline); + draw_text(font, text, sub_v2(pos, (v2){.x = -outline_width, .y = outline_width}), outline); + draw_text(font, text, sub_v2(pos, (v2){.x = -outline_width, .y = -outline_width}), outline); + + v2 result = draw_text(font, text, pos, colour); + + return result; +} + static v2 draw_text_r(Font font, s8 text, v2 pos, f32 rotation, Color colour) { @@ -746,9 +760,8 @@ draw_beamform_view(BeamformerCtx *ctx, Arena a, v2 mouse, BeamformerFrameView *v .x = vr.pos.x + vr.size.w - txt_s.w - 16, .y = vr.pos.y + 4, }; - draw_text(ui->font, shader, txt_p, fade(BLACK, 0.8)); - txt_p = floor_v2(sub_v2(txt_p, (v2){.x = -1.5, .y = -1.5})); - draw_text(ui->font, shader, txt_p, colour_from_normalized(RULER_COLOUR)); + draw_outlined_text(ui->font, shader, txt_p, 1, + colour_from_normalized(RULER_COLOUR), BLACK); } /* TODO(rnp): store converted ruler points instead of screen points */