This repository was archived by the owner on Nov 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpxpat.h
73 lines (58 loc) · 2.06 KB
/
pxpat.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#ifndef PXPAT_H_
#define PXPAT_H_
enum pat_error {
PXPAT_E_SUCCESS = 0,
PXPAT_E_INVALID_PARAMETERS,
PXPAT_E_MAP_ENTRIES_EXCEEDED
};
enum pat_limits {
PXPAT_TGA_MAP_ENTRIES_MAX = 255
};
enum pat_filefmt {
PXPAT_FFMT_TGA
};
struct pattern;
typedef unsigned char pat_getpx_func(struct pattern *, unsigned int); /* returns a color index from Pattern.rgb */
enum pat_flags {
PXPAT_F_NONE = 0,
PXPAT_F_TILE = 1
};
struct pattern {
unsigned int w, h;
unsigned char *data;
unsigned long *rgb; /* for hex triplets (each using 3 bytes out of 4 bytes~) */
unsigned int nrgb;
pat_getpx_func *getpx;
enum pat_flags f;
};
struct pat_getpx_func_table {
const char *name;
pat_getpx_func *getpx;
};
extern const struct pat_getpx_func_table pat_getpx_funcs[];
unsigned char pat_getpx(struct pattern *pat, unsigned int pos);
unsigned char pat_getpx_simple_rand(struct pattern *pat, unsigned int pos);
unsigned char pat_getpx_grid(struct pattern *pat, unsigned int pos);
unsigned char pat_getpx_cycle_colors(struct pattern *pat, unsigned int pos);
unsigned char pat_getpx_checkpat(struct pattern *pat, unsigned int pos);
unsigned char pat_getpx_main_diag(struct pattern *pat, unsigned int pos);
void pat_gen(struct pattern *pat);
void pat_write_tga(struct pattern pat, FILE *fp, unsigned int pxsz);
pat_getpx_func *pat_get_getpx_by_name(const char *name);
struct pat_context {
struct pattern pat;
unsigned int pxsz, seed;
enum pat_error err;
};
struct pat_context pat_ctx_new(unsigned int w,
unsigned int h,
unsigned int pxsz,
const char *rgb_s[],
unsigned int nrgb,
unsigned int seed,
const char *getpx_name,
enum pat_flags f);
void pat_ctx_write(struct pat_context *ctx, FILE *fp, enum pat_filefmt ffmt);
void pat_ctx_free(struct pat_context *ctx);
const char *pat_strerror(struct pat_context *ctx);
#endif /* PXPAT_H_ */