|
ginnOS
The reference: libc, the libraries and the kernel
|
libgfx: colours, rectangles, buffers, fills, copies and output. More...
Functions | |
| 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. | |
| 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. | |
| gfx_color_t | gfx_over (gfx_color_t dst, gfx_color_t src) |
| a source pixel over a destination pixel (Porter-Duff source over). | |
| 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. | |
| gfx_rect_t | gfx_rect_intersect (gfx_rect_t a, gfx_rect_t b) |
| the part two rectangles share (empty if none). | |
| 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). | |
| bool | gfx_rect_contains (gfx_rect_t r, int32_t x, int32_t y) |
| gfx_buffer_t * | gfx_buffer_new (int32_t width, int32_t height) |
| a new buffer of transparent pixels, from malloc. | |
| void | gfx_buffer_free (gfx_buffer_t *buf) |
| free a buffer from gfx_buffer_new (and its pixels, if it owns them). | |
| 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). | |
| 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. | |
| void | gfx_set_clip (gfx_buffer_t *buf, gfx_rect_t clip) |
| set the clip rectangle (it is clipped to the buffer). | |
| void | gfx_reset_clip (gfx_buffer_t *buf) |
| make the whole buffer the clip rectangle. | |
| void | gfx_clear (gfx_buffer_t *buf, gfx_color_t color) |
| set every pixel in the clip rectangle to a colour (no blending). | |
| void | gfx_fill_rect (gfx_buffer_t *buf, gfx_rect_t r, gfx_color_t color) |
| fill a rectangle, blended over what is there. | |
| 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. | |
| 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). | |
| 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). | |
| 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). | |
| 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, y). | |
| 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. | |
libgfx: colours, rectangles, buffers, fills, copies and output.
| 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.
| 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.
| gfx_color_t gfx_over | ( | gfx_color_t | dst, |
| gfx_color_t | src ) |
a source pixel over a destination pixel (Porter-Duff source over).
| 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.
| gfx_rect_t gfx_rect_intersect | ( | gfx_rect_t | a, |
| gfx_rect_t | b ) |
the part two rectangles share (empty if none).
| 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).
| bool gfx_rect_contains | ( | gfx_rect_t | r, |
| int32_t | x, | ||
| int32_t | y ) |
| gfx_buffer_t * gfx_buffer_new | ( | int32_t | width, |
| int32_t | height ) |
a new buffer of transparent pixels, from malloc.
| void gfx_buffer_free | ( | gfx_buffer_t * | buf | ) |
free a buffer from gfx_buffer_new (and its pixels, if it owns them).
| 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).
the clip rectangle is the whole buffer.
| stride | pixels from one row to the next. |
| 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.
the rectangle is clipped to the parent. it is not freed on its own.
| void gfx_set_clip | ( | gfx_buffer_t * | buf, |
| gfx_rect_t | clip ) |
set the clip rectangle (it is clipped to the buffer).
| void gfx_reset_clip | ( | gfx_buffer_t * | buf | ) |
make the whole buffer the clip rectangle.
| void gfx_clear | ( | gfx_buffer_t * | buf, |
| gfx_color_t | color ) |
set every pixel in the clip rectangle to a colour (no blending).
| void gfx_fill_rect | ( | gfx_buffer_t * | buf, |
| gfx_rect_t | r, | ||
| gfx_color_t | color ) |
fill a rectangle, blended over what is there.
| 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.
| 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).
for backgrounds.
| 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).
the buffers may be the same one, and the parts may overlap.
| 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).
| 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, y).
text and line icons are drawn this way.
| stride | bytes from one mask row to the next. |
| 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.
the pixels are taken as over black (alpha is dropped).
| fb | the framebuffer's first pixel. |
| fb_pitch | bytes from one framebuffer row to the next. |
| fb_width | the framebuffer's size, to clip to. |
| src_rect | the part of src; it goes to the same place on the framebuffer. |