65#define GFX_TRANSPARENT ((gfx_color_t)0)
105static inline bool gfx_rect_empty(
gfx_rect_t r)
107 return r.
w <= 0 || r.
h <= 0;
gfx_color_t gfx_over(gfx_color_t dst, gfx_color_t src)
a source pixel over a destination pixel (Porter-Duff source over).
Definition gfx.c:21
void gfx_stroke_rect(gfx_buffer_t *buf, gfx_rect_t r, int32_t thickness, gfx_color_t color)
the edges of a rectangle, thickness pixels wide, on the inside.
Definition gfx.c:149
void gfx_clear(gfx_buffer_t *buf, gfx_color_t color)
set every pixel in the clip rectangle to a colour (no blending).
Definition gfx.c:131
gfx_rect_t gfx_rect_union(gfx_rect_t a, gfx_rect_t b)
the smallest rectangle that holds both (an empty one counts as none).
Definition gfx.c:42
gfx_rect_t gfx_rect_intersect(gfx_rect_t a, gfx_rect_t b)
the part two rectangles share (empty if none).
Definition gfx.c:31
void gfx_fill_rect(gfx_buffer_t *buf, gfx_rect_t r, gfx_color_t color)
fill a rectangle, blended over what is there.
Definition gfx.c:142
void gfx_set_clip(gfx_buffer_t *buf, gfx_rect_t clip)
set the clip rectangle (it is clipped to the buffer).
Definition gfx.c:106
void gfx_reset_clip(gfx_buffer_t *buf)
make the whole buffer the clip rectangle.
Definition gfx.c:111
void gfx_buffer_free(gfx_buffer_t *buf)
free a buffer from gfx_buffer_new (and its pixels, if it owns them).
Definition gfx.c:77
gfx_color_t gfx_rgba(uint8_t r, uint8_t g, uint8_t b, uint8_t a)
a colour with alpha, from straight (not premultiplied) channels.
Definition gfx.c:11
void gfx_present(void *fb, uint32_t fb_pitch, int32_t fb_width, int32_t fb_height, const gfx_format_t *format, const gfx_buffer_t *src, gfx_rect_t src_rect)
copy a part of a buffer to a framebuffer, in its pixel format.
Definition gfx.c:261
bool gfx_rect_contains(gfx_rect_t r, int32_t x, int32_t y)
Definition gfx.c:55
void gfx_buffer_init(gfx_buffer_t *buf, uint32_t *pixels, int32_t width, int32_t height, int32_t stride)
make a buffer over memory the caller owns (a shared memory mapping, for example).
Definition gfx.c:86
gfx_buffer_t gfx_buffer_sub(const gfx_buffer_t *parent, gfx_rect_t r)
a buffer for a part of another buffer: the same pixels, its own clip.
Definition gfx.c:97
gfx_color_t gfx_fade(gfx_color_t c, uint8_t opacity)
a colour with its alpha (and so its premultiplied channels) scaled by opacity / 255.
Definition gfx.c:16
gfx_buffer_t * gfx_buffer_new(int32_t width, int32_t height)
a new buffer of transparent pixels, from malloc.
Definition gfx.c:60
void gfx_draw_mask(gfx_buffer_t *dst, int32_t x, int32_t y, const uint8_t *mask, int32_t width, int32_t height, int32_t stride, gfx_color_t color)
a coverage mask (one byte per pixel, 0 to 255) in a colour, blended over dst with its top left at (x,...
Definition gfx.c:239
void gfx_copy(gfx_buffer_t *dst, int32_t x, int32_t y, const gfx_buffer_t *src, gfx_rect_t src_rect)
copy a part of src to dst at (x, y), replacing the pixels (no blending).
Definition gfx.c:199
gfx_color_t gfx_mix(gfx_color_t a, gfx_color_t b, uint8_t amount)
a mix of two colours, as CSS color-mix in sRGB: amount of b (0 to 255) and the rest of a.
Definition gfx.c:26
void gfx_fill_gradient(gfx_buffer_t *buf, gfx_rect_t r, gfx_color_t top, gfx_color_t bottom)
a vertical gradient from top to bottom colour over a rectangle (replacing the pixels).
Definition gfx.c:167
void gfx_blend(gfx_buffer_t *dst, int32_t x, int32_t y, const gfx_buffer_t *src, gfx_rect_t src_rect, uint8_t opacity)
blend a part of src over dst at (x, y), with an opacity (255: as it is).
Definition gfx.c:218
uint32_t gfx_color_t
a premultiplied ARGB colour, 0xAARRGGBB.
Definition gfx.h:30
void gfx_blur(gfx_buffer_t *buf, double sigma)
blur the whole buffer like a Gaussian with this sigma (in pixels); the edge pixels are used again pas...
Definition gfx_blur.c:47
void gfx_border_round_rect(gfx_buffer_t *buf, gfx_rect_t r, int32_t radius, int32_t width, gfx_color_t color)
the border of a round rectangle: width pixels wide, inside r (as a CSS border with box-sizing: border...
Definition gfx_round.c:135
void gfx_box_shadow(gfx_buffer_t *buf, gfx_rect_t box, int32_t radius, const gfx_shadow_t *s)
draw a box-shadow of a round box.
Definition gfx_round.c:273
void gfx_fill_round_rect(gfx_buffer_t *buf, gfx_rect_t r, int32_t radius, gfx_color_t color)
fill a rectangle with round corners, with anti-aliased corners (as CSS border-radius).
Definition gfx_round.c:130
void gfx_fill_round_rect_gradient(gfx_buffer_t *buf, gfx_rect_t r, int32_t radius, gfx_color_t top, gfx_color_t bottom)
fill a round rectangle with a vertical gradient from top to bottom, sampled at the pixel centres (as ...
Definition gfx_round.c:116
void gfx_blend_scaled(gfx_buffer_t *dst, gfx_rect_t dst_rect, const gfx_buffer_t *src, gfx_rect_t src_rect, uint8_t opacity)
draw a part of src scaled to fill dst_rect, blended over dst, with bilinear filtering.
Definition gfx_scale.c:47
void gfx_line(gfx_buffer_t *buf, int32_t x0, int32_t y0, int32_t x1, int32_t y1, gfx_color_t color)
a line one pixel wide from (x0, y0) to (x1, y1), both ends included, blended over what is there.
Definition gfx_shapes.c:8
unsigned int uint32_t
Definition fb.h:17
unsigned char uint8_t
Definition fb.h:18
NULL, size_t, ptrdiff_t, offsetof.
__PTRDIFF_TYPE__ ptrdiff_t
Definition stddef.h:14
integer types of fixed width.
int int32_t
Definition stdint.h:14
bool owned
Definition gfx.h:47
int32_t stride
Definition gfx.h:45
uint32_t * pixels
Definition gfx.h:42
int32_t width
Definition gfx.h:43
int32_t height
Definition gfx.h:44
gfx_rect_t clip
Definition gfx.h:46
int32_t y
Definition gfx.h:35
int32_t x
Definition gfx.h:34
int32_t h
Definition gfx.h:37
int32_t w
Definition gfx.h:36
a CSS box-shadow: "x y blur spread color", and "inset".
Definition gfx.h:202
int32_t x
Definition gfx.h:203
bool inset
Definition gfx.h:208
int32_t blur
Definition gfx.h:205
int32_t spread
Definition gfx.h:206
gfx_color_t color
Definition gfx.h:207
int32_t y
Definition gfx.h:204