RMGui 0.15.0
C11 retained-mode UI library: layout kernel, style schema, widget painters, fonts, software framebuffer
Loading...
Searching...
No Matches
emboss.h File Reference

emboss.h — relief from a coverage mask: the edge of a shape that faces the light is lightened and the edge turned away is darkened, so a flat element reads as raised from, or pressed into, its surface. More...

#include "fb.h"
#include "geom.h"
#include "mask.h"

Enumerations

enum  rmgui_emboss_direction_t {
  RMGUI_EMBOSS_LIGHT_N , RMGUI_EMBOSS_LIGHT_NE , RMGUI_EMBOSS_LIGHT_E , RMGUI_EMBOSS_LIGHT_SE ,
  RMGUI_EMBOSS_LIGHT_S , RMGUI_EMBOSS_LIGHT_SW , RMGUI_EMBOSS_LIGHT_W , RMGUI_EMBOSS_LIGHT_NW
}
 The direction the light comes from. More...
enum  rmgui_emboss_relief_t { RMGUI_EMBOSS_RAISED , RMGUI_EMBOSS_RECESSED }
 RAISED: the shape stands out, so its edge toward the light is lit. More...

Functions

void rmgui_draw_emboss (rmgui_fb_t *fb, rmgui_rect_t rect, const rmgui_mask_t *mask, int depth_px, rmgui_emboss_direction_t direction, rmgui_emboss_relief_t relief, rmgui_color_t light, rmgui_color_t dark, rmgui_rect_t clip)
 Paints the relief of mask stretched over rect (the nearest-pixel mapping of mask.h) onto fb.

Detailed Description

emboss.h — relief from a coverage mask: the edge of a shape that faces the light is lightened and the edge turned away is darkened, so a flat element reads as raised from, or pressed into, its surface.

Enumeration Type Documentation

◆ rmgui_emboss_direction_t

The direction the light comes from.

Enumerator
RMGUI_EMBOSS_LIGHT_N 
RMGUI_EMBOSS_LIGHT_NE 
RMGUI_EMBOSS_LIGHT_E 
RMGUI_EMBOSS_LIGHT_SE 
RMGUI_EMBOSS_LIGHT_S 
RMGUI_EMBOSS_LIGHT_SW 
RMGUI_EMBOSS_LIGHT_W 
RMGUI_EMBOSS_LIGHT_NW 

◆ rmgui_emboss_relief_t

RAISED: the shape stands out, so its edge toward the light is lit.

RECESSED: the shape is pressed in, so its edge toward the light is in shadow and the edge away from it is lit.

Enumerator
RMGUI_EMBOSS_RAISED 
RMGUI_EMBOSS_RECESSED 

Function Documentation

◆ rmgui_draw_emboss()

void rmgui_draw_emboss ( rmgui_fb_t * fb,
rmgui_rect_t rect,
const rmgui_mask_t * mask,
int depth_px,
rmgui_emboss_direction_t direction,
rmgui_emboss_relief_t relief,
rmgui_color_t light,
rmgui_color_t dark,
rmgui_rect_t clip )

Paints the relief of mask stretched over rect (the nearest-pixel mapping of mask.h) onto fb.

Let v(p) be the coverage (0..255) at point p, 0 outside rect, and u the unit step toward the light (a diagonal light steps one px in x and one in y). For each pixel p of rect: toward = max(0, v(p) - v(p + depth_px * u)) the edge facing the light, away = max(0, v(p) - v(p - depth_px * u)) the edge turned from it. The toward-side colour (light for RAISED, dark for RECESSED) is blended over p with its alpha scaled by toward (alpha * toward / 255, rounded), then the other colour likewise by away, each by the straight-over rule of draw.h. A pixel whose toward and away are both 0 is left unchanged: every pixel outside the shape, and every pixel inside it further than depth_px from the shape's edges along u, so only a band up to depth_px wide inside each edge changes.

Painting is clipped to fb and to clip; the mask is always read in full. Nothing is painted when fb is NULL or empty, mask is NULL or empty (width, height or coverage not set), rect has a non-positive extent, depth_px is not positive, or direction or relief is outside its enum.