-
Notifications
You must be signed in to change notification settings - Fork 4
/
draw.h
52 lines (42 loc) · 1.29 KB
/
draw.h
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
52
/*
* Copyright (C) 2020 Bootlin
*/
#ifndef _DRAW_H_
#define _DRAW_H_
struct draw_buffer {
void *data;
unsigned int size;
unsigned int width;
unsigned int height;
unsigned int stride;
};
struct draw_mandelbrot {
float center_x;
float center_y;
float view_width;
float view_height;
float zoom;
float bounds_x[2];
float bounds_y[2];
float iterations_zoom;
unsigned int iterations;
};
static inline uint32_t *draw_buffer_pixel(struct draw_buffer *buffer,
unsigned int x, unsigned int y)
{
unsigned int offset = y * buffer->stride + x * sizeof(uint32_t);
return (uint32_t *)(buffer->data + offset);
}
struct draw_buffer *draw_buffer_create(unsigned int width, unsigned int height);
void draw_buffer_destroy(struct draw_buffer *buffer);
void draw_png(struct draw_buffer *buffer, char *path);
void draw_gradient(struct draw_buffer *buffer);
void draw_background(struct draw_buffer *buffer, uint32_t color);
void draw_rectangle(struct draw_buffer *buffer, unsigned int x_start,
unsigned int y_start, unsigned int width,
unsigned int height, uint32_t color);
void draw_mandelbrot(struct draw_mandelbrot *mandelbrot,
struct draw_buffer *buffer);
void draw_mandelbrot_zoom(struct draw_mandelbrot *mandelbrot);
void draw_mandelbrot_init(struct draw_mandelbrot *mandelbrot);
#endif