colourpicker

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

Commit: ad7d7f55eea08912fdb7e516f2263539ebe4726d
Parent: fd6eaac296306ff16ef8c33478f016d70b452cb1
Author: Randy Palamar
Date:   Thu,  8 Aug 2024 21:04:26 -0600

adapt slider border radius to window scaling

Diffstat:
Mcolourpicker.c | 4+++-
Mutil.c | 3+--
2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/colourpicker.c b/colourpicker.c @@ -716,7 +716,9 @@ static void do_slider_shader(ColourPickerCtx *ctx, Rect r, i32 colour_mode, f32 *regions, f32 *colours) { f32 border_thick = SLIDER_BORDER_WIDTH; - f32 radius = SLIDER_BORDER_RADIUS; + f32 radius = SLIDER_ROUNDNESS / 2; + /* NOTE: scale radius by rect width or height to adapt to window scaling */ + radius *= (r.size.w > r.size.h)? r.size.h : r.size.w; BeginShaderMode(ctx->picker_shader); rlEnableShader(ctx->picker_shader.id); diff --git a/util.c b/util.c @@ -95,8 +95,7 @@ enum cardinal_direction { NORTH, EAST, SOUTH, WEST }; #define SLIDER_BORDER_COLOUR (Color){.r = 0x00, .g = 0x00, .b = 0x00, .a = 0xCC} #define SLIDER_BORDER_WIDTH 3.0f -#define SLIDER_ROUNDNESS 0.5f -#define SLIDER_BORDER_RADIUS 10.0f +#define SLIDER_ROUNDNESS 0.035f #define SLIDER_SCALE_SPEED 8.0f #define SLIDER_SCALE_TARGET 1.5f #define SLIDER_TRI_SIZE (v2){.x = 6, .y = 8}