aboutsummaryrefslogtreecommitdiff
path: root/src/canvas.h
blob: 4f520fe4a1ffeee5f50ab14ae918367cb883e347 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#ifndef IMV_CANVAS_H
#define IMV_CANVAS_H

struct imv_canvas;
struct imv_image;

enum upscaling_method {
  UPSCALING_LINEAR,
  UPSCALING_NEAREST_NEIGHBOUR,
  UPSCALING_METHOD_COUNT,
};

/* Create a canvas instance */
struct imv_canvas *imv_canvas_create(int width, int height);

/* Clean up a canvas */
void imv_canvas_free(struct imv_canvas *canvas);

/* Set the buffer size of the canvas */
void imv_canvas_resize(struct imv_canvas *canvas, int width, int height);

/* Blank the canvas to be empty and transparent */
void imv_canvas_clear(struct imv_canvas *canvas);

/* Set the current drawing color of the canvas */
void imv_canvas_color(struct imv_canvas *canvas, float r, float g, float b, float a);

/* Fill a rectangle on the canvas with the current color */
void imv_canvas_fill_rectangle(struct imv_canvas *canvas, int x, int y, int width, int height);

/* Fill the whole canvas with the current color */
void imv_canvas_fill(struct imv_canvas *canvas);

/* Fill the whole canvas with a chequerboard pattern */
void imv_canvas_fill_checkers(struct imv_canvas *canvas, int size);

/* Select the font to draw text with */
void imv_canvas_font(struct imv_canvas *canvas, const char *name, int size);

/* Draw some text on the canvas */
void imv_canvas_printf(struct imv_canvas *canvas, int x, int y, const char *fmt, ...);

/* Blit the canvas to the current OpenGL framebuffer */
void imv_canvas_draw(struct imv_canvas *canvas);

/* Blit the given image to the current OpenGL framebuffer */
void imv_canvas_draw_image(struct imv_canvas *canvas, struct imv_image *image,
                           int x, int y, double scale,
                           enum upscaling_method upscaling_method);

#endif