summaryrefslogtreecommitdiff
path: root/include/painter/color.h
blob: 2aeee3e947bc5b412869c848833effef2bf6c9af (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
52
53
54
55
56
57
58
59
60
61
#ifndef UPEM_MORPHING_COLOR
#define UPEM_MORPHING_COLOR

/**
 * File: color.h
 *
 * See also:
 *   A rainbow
 */

#include <MLV/MLV_color.h>
#include <stdbool.h>
#include "common/time.h"

/**
 * Type: ColorComponent
 * Represents a single colour component of 32-bits RGBa tuple.
 */
typedef uint8_t ColorComponent;

/**
 * Type: ColorPixel
 * Represents a single RGBa coloured pixel.
 * Compatible with the libMLV representation.
 */
typedef union {
  struct {
    ColorComponent a, b, g, r;
  } rgba;

  MLV_Color mlv;
} Color;

/**
 * Function: color_equals
 * Compares the supplied colors.
 *
 * Parameters:
 *   c1 - the first color
 *   c2 - the second color
 *
 * Returns:
 *   T(c1 is the same color as c2)
 */
bool color_equals(Color c1, Color c2);

/**
 * Function: color_blend
 * Blends two colors.
 *
 * Parameters:
 *   origin   - the first color
 *   target   - the second color
 *   distance - the distance from the first color
 *
 * Returns:
 *   The blended color
 */
Color color_blend(Color origin, Color target, TimeVector distance);

#endif