-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathevolve_pixel.h
93 lines (76 loc) · 3.36 KB
/
evolve_pixel.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#ifndef EVOLVE_PIXEL_H
#define EVOLVE_PIXEL_H
#include "image.h"
/**
* Wrap position + offset to new_position with [0, size-1].
* Fails if position + offset exceed MAX_INT.
*/
size_t wrap(size_t position, int offset, size_t size);
/**
* Jitter value without underflow/overflow (bounce).
*/
unsigned char jitter(unsigned char value);
/**
* Evolve pixel dst_pixel based on src_pixel.
*/
void evolve_pixel_single_parent(Pixel *dst_pixel, const Pixel *src_pixel);
/**
* Evolve pixel dst_pixel based on two pixels, dad_pixel and mom_pixel.
*/
void evolve_pixel_dad_mom_genes(Pixel *dst_pixel, const Pixel *dad_pixel,
const Pixel *mom_pixel);
/**
* Evolve pixel by randomly copying mom or dad.
*/
void evolve_pixel_dad_or_mom(Pixel *dst_pixel, const Pixel *dad_pixel,
const Pixel *mom_pixel);
/**
* Evolve pixel dst_pixel based on three parent pixels.
*/
void evolve_pixel_3_parent_genes(Pixel *dst_pixel, const Pixel *parent_pixel1,
const Pixel *parent_pixel2,
const Pixel *parent_pixel3);
/**
* Evolve pixel dst_pixel based on two pixels, dad_pixel and mom_pixel,
* averaged.
*/
void evolve_pixel_dad_mom_average(Pixel *dst_pixel, const Pixel *dad_pixel,
const Pixel *mom_pixel);
void evolve_pixel_4_parent_genes(Pixel *dst_pixel, const Pixel *parent_pixel1,
const Pixel *parent_pixel2,
const Pixel *parent_pixel3,
const Pixel *parent_pixel4);
void evolve_pixel_4_parent_average(Pixel *dst_pixel,
const Pixel *parent_pixel1,
const Pixel *parent_pixel2,
const Pixel *parent_pixel3,
const Pixel *parent_pixel4);
void evolve_pixel_4_parent_pick_one(Pixel *dst_pixel,
const Pixel *parent_pixel1,
const Pixel *parent_pixel2,
const Pixel *parent_pixel3,
const Pixel *parent_pixel4);
void evolve_pixel_8_parent_pick_one(Pixel *dst_pixel,
const Pixel *parent_pixel1,
const Pixel *parent_pixel2,
const Pixel *parent_pixel3,
const Pixel *parent_pixel4,
const Pixel *parent_pixel5,
const Pixel *parent_pixel6,
const Pixel *parent_pixel7,
const Pixel *parent_pixel8);
unsigned char extremity(const Pixel *pixel, unsigned char rgb[3]);
/**
* Among the 8 parents, pick the one with the following maximized:
*
* max(r, g, b) - max2(r, g, b),
*
* where max2 means second greatest value.
*/
Pixel *most_extreme(Pixel **pixels, size_t n_pixels);
void evolve_pixel_8_parent_extreme(Pixel *dst_pixel, Pixel *parents[8]);
void evolve_pixel_3_parent_bright(Pixel *dst_pixel,
const Pixel *parent_pixel1,
const Pixel *parent_pixel2,
const Pixel *parent_pixel3);
#endif /* EVOLVE_PIXEL_H */