|
RMGui 0.15.0
C11 retained-mode UI library: layout kernel, style schema, widget painters, fonts, software framebuffer
|
Rounded-rectangle fills, strokes, borders and glows, without allocation. More...
Data Structures | |
| struct | rmgui_corner_radii_t |
| Corner radii in device pixels, clockwise from the top left. More... | |
| struct | rmgui_insets_t |
| Nonnegative integer pixel insets, clockwise from the top side. More... | |
Functions | |
| static rmgui_corner_radii_t | rmgui_corner_radii_uniform (int radius) |
| Four equal device-pixel radii, for a uniform face and its shadow. | |
| int | rmgui_rect_inset (rmgui_rect_t rect, rmgui_insets_t insets, rmgui_rect_t *out) |
| Store the rectangle inset on each side in out. | |
| int | rmgui_draw_fill_rounded_corners (rmgui_fb_t *fb, rmgui_rect_t clip, rmgui_rect_t rect, rmgui_corner_radii_t radii, rmgui_color_t color, rmgui_draw_mode_t mode) |
| Paint independent circular corners. | |
| int | rmgui_draw_border_rect (rmgui_fb_t *fb, rmgui_rect_t clip, rmgui_rect_t rect, rmgui_insets_t widths, rmgui_color_t color, rmgui_draw_mode_t mode) |
| Paint rect less its inset by the independent integer side widths. | |
| int | rmgui_draw_stroke_rounded (rmgui_fb_t *fb, rmgui_rect_t clip, rmgui_rect_t rect, rmgui_corner_radii_t radii, int32_t width_q16, rmgui_color_t color, rmgui_draw_mode_t mode) |
| Paint the rounded rect less its inset by width_q16 / 65536 device px. | |
| int | rmgui_draw_glow_rounded (rmgui_fb_t *fb, rmgui_rect_t clip, rmgui_rect_t rect, rmgui_corner_radii_t radii, int blur, rmgui_color_t color, rmgui_draw_mode_t mode) |
| Paint only pixel centres strictly outside the rounded rect. | |
Rounded-rectangle fills, strokes, borders and glows, without allocation.
Rounded-rectangle geometry and painters.
See geometry declarations for corner radii, uniform radii and rectangle inset contracts.
|
inlinestatic |
Four equal device-pixel radii, for a uniform face and its shadow.
| int rmgui_rect_inset | ( | rmgui_rect_t | rect, |
| rmgui_insets_t | insets, | ||
| rmgui_rect_t * | out ) |
Store the rectangle inset on each side in out.
Returns 0 on success; zero output extents are allowed. Returns -1 without changing out if it is null, any extent or inset is negative, opposing insets exceed the corresponding extent, or an inset origin is not representable as int. Sums are checked in widened arithmetic; the input coordinates may be arbitrary int values.
| int rmgui_draw_fill_rounded_corners | ( | rmgui_fb_t * | fb, |
| rmgui_rect_t | clip, | ||
| rmgui_rect_t | rect, | ||
| rmgui_corner_radii_t | radii, | ||
| rmgui_color_t | color, | ||
| rmgui_draw_mode_t | mode ) |
Paint independent circular corners.
Samples strictly inside the shape contribute coverage on draw.h's 16 x 16 sample grid. Paint once at alpha (color.a * coverage + 128) / 256, in mode's OVER or ADD rule. Work and writes are confined to rect intersect clip intersect fb. Arbitrary int coordinates are safe. Returns 0, including empty fb/rect/clip or transparent color; -1 unchanged for NULL fb or invalid mode.
| int rmgui_draw_border_rect | ( | rmgui_fb_t * | fb, |
| rmgui_rect_t | clip, | ||
| rmgui_rect_t | rect, | ||
| rmgui_insets_t | widths, | ||
| rmgui_color_t | color, | ||
| rmgui_draw_mode_t | mode ) |
Paint rect less its inset by the independent integer side widths.
Each border pixel is composited exactly once, including the corners, using mode's OVER or ADD rule. Work and writes are confined to rect intersect clip intersect fb. Returns -1 unchanged for NULL fb, invalid mode or any rmgui_rect_inset refusal; otherwise 0, including empty fb/rect/clip, zero widths or transparent color.
| int rmgui_draw_stroke_rounded | ( | rmgui_fb_t * | fb, |
| rmgui_rect_t | clip, | ||
| rmgui_rect_t | rect, | ||
| rmgui_corner_radii_t | radii, | ||
| int32_t | width_q16, | ||
| rmgui_color_t | color, | ||
| rmgui_draw_mode_t | mode ) |
Paint the rounded rect less its inset by width_q16 / 65536 device px.
The width is rounded to 1/256 px, halves up (a rounded zero paints nothing); each inner radius is max(outer radius - rounded width, 0). An empty inner rect covers nothing. Samples strictly inside the outer shape but not strictly inside the inner shape contribute coverage on draw.h's 16 x 16 sample grid. Paint once at alpha (color.a * coverage + 128) / 256, using mode's OVER or ADD rule. Writes are confined to rect intersect clip intersect fb. Arbitrary int coordinates are safe; work is bounded by that intersection's pixels. Returns 0 (also for an empty fb, rect or clip, or transparent color), or -1 unchanged for NULL fb, an invalid mode, width_q16 <= 0, or width_q16 greater than min(rect.w, rect.h) * 32768 for a nonempty rect.
| int rmgui_draw_glow_rounded | ( | rmgui_fb_t * | fb, |
| rmgui_rect_t | clip, | ||
| rmgui_rect_t | rect, | ||
| rmgui_corner_radii_t | radii, | ||
| int | blur, | ||
| rmgui_color_t | color, | ||
| rmgui_draw_mode_t | mode ) |
Paint only pixel centres strictly outside the rounded rect.
Let d be their Euclidean distance to its boundary. Round d to 1/256 px, halves up, obtaining D, and let B = blur * 256. Centres inside or on the boundary, and D >= B, are untouched. Otherwise paint once at alpha round(color.a * (B-D)^2 * (B+2D) / B^3), halves up, in mode's OVER or ADD rule. RGB is color's straight RGB. There is no animation state: callers animate the glow by changing color.a. Writes and work are bounded by rect grown by blur, intersect clip intersect fb; the rect interior is untouched. Coordinates may be arbitrary ints. Returns 0, including for empty fb/rect/clip or transparent color; -1 unchanged for NULL fb, an invalid mode, or blur <= 0. Every positive int blur is supported.