|
RMGui 0.15.0
C11 retained-mode UI library: layout kernel, style schema, widget painters, fonts, software framebuffer
|
backdrop.h — stylized backgrounds: a 256-entry palette built from colour stops (typically the active scheme's colours), radial and noise fields mapped through it, and wrap-around tiles for scrolling and parallax. More...
#include <stddef.h>#include <stdint.h>#include "draw.h"#include "fb.h"#include "geom.h"#include "mask.h"Data Structures | |
| struct | rmgui_backdrop_stop_t |
| A palette stop: color (straight RGBA) sits at index at. More... | |
| struct | rmgui_backdrop_palette_t |
| 256 straight RGBA colours indexed by a field value. More... | |
Functions | |
| int | rmgui_backdrop_palette (rmgui_backdrop_palette_t *out, const rmgui_backdrop_stop_t *stops, size_t count) |
| Builds out from count stops with strictly increasing at: entries up to the first stop take its colour, entries from the last stop take its colour, and entries between stops s0 and s1 take, per channel, c0 + (c1 - c0) * (i - s0.at) / (s1.at - s0.at) (C truncation). | |
| void | rmgui_backdrop_radial (rmgui_fb_t *fb, rmgui_rect_t rect, int center_x, int center_y, int radius, const rmgui_backdrop_palette_t *palette, rmgui_draw_mode_t mode) |
| Paints the radial field centred on (center_x, center_y): pixel (x, y) takes palette entry round(255 * sqrt(t / 4096)) (halves up), where t = min(4096, floor(4096 * d2 / radius^2)) and d2 is the squared distance of the pixel from the centre; for radius > 5792, d2 and radius^2 are first both shifted right by the least s that brings radius^2 >> s below 2^25. | |
| void | rmgui_backdrop_noise (rmgui_fb_t *fb, rmgui_rect_t rect, uint32_t seed, int cell_log2, int offset_x, int offset_y, const rmgui_backdrop_palette_t *palette, rmgui_draw_mode_t mode) |
| Paints smooth 2-D value noise: lattice cells of 2^cell_log2 px, the grid shifted by (offset_x, offset_y) to scroll it (pixel (x, y) samples the field at (x + offset_x, y + offset_y)), each lattice value an 8-bit hash of (cell x, cell y, seed), bilinearly joined through an 8-bit smoothstep; the value indexes palette, in mode. | |
| void | rmgui_backdrop_tile (rmgui_fb_t *fb, rmgui_rect_t rect, const rmgui_fb_t *tile, int offset_x, int offset_y, rmgui_draw_mode_t mode) |
| Covers rect with tile repeated, tile pixel ((x - rect.x + offset_x) mod tile.w, (y - rect.y + offset_y) mod tile.h) landing on (x, y). | |
| void | rmgui_backdrop_tile_shaped (rmgui_fb_t *fb, rmgui_rect_t rect, const rmgui_fb_t *tile, int offset_x, int offset_y, const rmgui_mask_t *shape, rmgui_draw_mode_t mode) |
| rmgui_backdrop_tile through the coverage mask shape (mask.h), stretched over rect by mask.h's nearest-pixel rule: the tile pixel landing on (x, y), with the same offsets, is first scaled by the coverage c (0..255) of shape there, every one of its four premultiplied channels becoming round(channel * c / 255) (halves up), and is then composited as rmgui_backdrop_tile composites it. | |
| void | rmgui_backdrop_tile_nine (rmgui_fb_t *fb, rmgui_rect_t rect, rmgui_rect_t clip, const rmgui_fb_t *tile, int offset_x, int offset_y, const rmgui_mask_nine_t *shape, rmgui_draw_mode_t mode) |
| rmgui_backdrop_tile through the nine-slice shape shape (mask.h) laid over rect, written only inside clip: the tile pixel landing on (x, y) is the one rmgui_backdrop_tile puts there for the same rect and offsets, scaled by the shape's coverage as rmgui_backdrop_tile_shaped scales it. | |
backdrop.h — stylized backgrounds: a 256-entry palette built from colour stops (typically the active scheme's colours), radial and noise fields mapped through it, and wrap-around tiles for scrolling and parallax.
Every painter writes only inside rect intersected with fb, and costs the pixels it covers.
| int rmgui_backdrop_palette | ( | rmgui_backdrop_palette_t * | out, |
| const rmgui_backdrop_stop_t * | stops, | ||
| size_t | count ) |
Builds out from count stops with strictly increasing at: entries up to the first stop take its colour, entries from the last stop take its colour, and entries between stops s0 and s1 take, per channel, c0 + (c1 - c0) * (i - s0.at) / (s1.at - s0.at) (C truncation).
Returns 0; -1, leaving *out unchanged, when a pointer is NULL, count is 0 or above 256 (the uint8_t stop index domain), or at does not increase.
| void rmgui_backdrop_radial | ( | rmgui_fb_t * | fb, |
| rmgui_rect_t | rect, | ||
| int | center_x, | ||
| int | center_y, | ||
| int | radius, | ||
| const rmgui_backdrop_palette_t * | palette, | ||
| rmgui_draw_mode_t | mode ) |
Paints the radial field centred on (center_x, center_y): pixel (x, y) takes palette entry round(255 * sqrt(t / 4096)) (halves up), where t = min(4096, floor(4096 * d2 / radius^2)) and d2 is the squared distance of the pixel from the centre; for radius > 5792, d2 and radius^2 are first both shifted right by the least s that brings radius^2 >> s below 2^25.
Painted in mode. When entry 255 is fully transparent only the disc is visited. radius <= 0 paints nothing.
| void rmgui_backdrop_noise | ( | rmgui_fb_t * | fb, |
| rmgui_rect_t | rect, | ||
| uint32_t | seed, | ||
| int | cell_log2, | ||
| int | offset_x, | ||
| int | offset_y, | ||
| const rmgui_backdrop_palette_t * | palette, | ||
| rmgui_draw_mode_t | mode ) |
Paints smooth 2-D value noise: lattice cells of 2^cell_log2 px, the grid shifted by (offset_x, offset_y) to scroll it (pixel (x, y) samples the field at (x + offset_x, y + offset_y)), each lattice value an 8-bit hash of (cell x, cell y, seed), bilinearly joined through an 8-bit smoothstep; the value indexes palette, in mode.
cell_log2 outside 1..8 paints nothing.
| void rmgui_backdrop_tile | ( | rmgui_fb_t * | fb, |
| rmgui_rect_t | rect, | ||
| const rmgui_fb_t * | tile, | ||
| int | offset_x, | ||
| int | offset_y, | ||
| rmgui_draw_mode_t | mode ) |
Covers rect with tile repeated, tile pixel ((x - rect.x + offset_x) mod tile.w, (y - rect.y + offset_y) mod tile.h) landing on (x, y).
The tile holds premultiplied RGBA; OVER composites it premultiplied (an opaque pixel is a copy), ADD adds it. An empty tile, or tile == fb, paints nothing.
| void rmgui_backdrop_tile_shaped | ( | rmgui_fb_t * | fb, |
| rmgui_rect_t | rect, | ||
| const rmgui_fb_t * | tile, | ||
| int | offset_x, | ||
| int | offset_y, | ||
| const rmgui_mask_t * | shape, | ||
| rmgui_draw_mode_t | mode ) |
rmgui_backdrop_tile through the coverage mask shape (mask.h), stretched over rect by mask.h's nearest-pixel rule: the tile pixel landing on (x, y), with the same offsets, is first scaled by the coverage c (0..255) of shape there, every one of its four premultiplied channels becoming round(channel * c / 255) (halves up), and is then composited as rmgui_backdrop_tile composites it.
A tile pixel scaled to zero changes nothing, so c == 255 everywhere paints exactly what rmgui_backdrop_tile paints and c == 0 paints nothing; an anti-aliased mask gives soft edges. The stretch maps rect (not the part inside fb) to the whole mask.
Paints nothing on rmgui_backdrop_tile's refusals, and when shape is NULL or empty.
| void rmgui_backdrop_tile_nine | ( | rmgui_fb_t * | fb, |
| rmgui_rect_t | rect, | ||
| rmgui_rect_t | clip, | ||
| const rmgui_fb_t * | tile, | ||
| int | offset_x, | ||
| int | offset_y, | ||
| const rmgui_mask_nine_t * | shape, | ||
| rmgui_draw_mode_t | mode ) |
rmgui_backdrop_tile through the nine-slice shape shape (mask.h) laid over rect, written only inside clip: the tile pixel landing on (x, y) is the one rmgui_backdrop_tile puts there for the same rect and offsets, scaled by the shape's coverage as rmgui_backdrop_tile_shaped scales it.
Clipping never shifts the tile or the shape.
Paints nothing on rmgui_backdrop_tile's refusals, when shape is NULL, or when rect is narrower than the shape's left and right bands or shorter than its top and bottom bands.