colourpicker

Simple Colour Picker written in C
git clone anongit@rnpnr.xyz:colourpicker.git
Log | Files | Refs | Feed | Submodules | README | LICENSE

Commit: d1a932ba26509a39e6d691840dda31a7d2e5a48c
Parent: 00a72ebe67ed756a17574691c9f03b823e5ac45e
Author: Randy Palamar
Date:   Wed, 24 Jul 2024 21:56:52 -0600

clean up colour stack edges

Diffstat:
Mcolourpicker.c | 14++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/colourpicker.c b/colourpicker.c @@ -43,6 +43,16 @@ right_align_text_in_rect(Rect r, const char *text, Font font, f32 fontsize) }; } +static Rect +scale_rect_centered(Rect r, f32 scale) +{ + r.pos.x += ABS(1 - scale) / 2 * r.size.w; + r.pos.y += ABS(1 - scale) / 2 * r.size.h; + r.size.h *= scale; + r.size.w *= scale; + return r; +} + static v2 center_align_text_in_rect(Rect r, const char *text, Font font, f32 fontsize) { @@ -344,8 +354,8 @@ do_colour_stack_item(ColourPickerCtx *ctx, v2 mouse, Rect r, i32 item_idx, b32 f }; Color disp = colour_from_normalized(colour); DrawRectangleRounded(draw_rect.rr, STACK_ROUNDNESS, 0, Fade(disp, 1 - fade_param)); - DrawRectangleRoundedLinesEx(draw_rect.rr, STACK_ROUNDNESS, 0, 3.0, - Fade(BLACK, 1 - fade_param)); + draw_rect = scale_rect_centered(draw_rect, 0.96); + DrawRectangleRoundedLinesEx(draw_rect.rr, STACK_ROUNDNESS, 0, 3.0, Fade(BLACK, 1 - fade_param)); } static void