-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcolor.c
70 lines (53 loc) · 1.87 KB
/
color.c
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
/**
* @file color.c Color: manipulaçăo de cores.
*
* @author
* - Maira Noronha
* - Thiago Bastos
*
* @date
* Criado em: 1 de Dezembro de 2002
* Última Modificaçăo: 22 de Janeiro de 2003
*
* @version 2.0
*/
#include "color.h"
#include <stdio.h>
/************************************************************************/
/* Constantes Privadas */
/************************************************************************/
#define MAX( a, b ) ( ( a > b ) ? a : b )
#define MIN( a, b ) ( ( a < b ) ? a : b )
/************************************************************************/
/* Definiçőes das Funçőes Exportadas */
/************************************************************************/
Color colorCreate3b( unsigned char red, unsigned char green, unsigned char blue )
{
Color color= { (float)( red / 255.0 ), (float)( green / 255.0 ), (float)( blue / 255.0 ) };
return color;
}
Color colorAddition( Color c1, Color c2 )
{
Color color = { (float)( c1.red + c2.red ), (float)( c1.green + c2.green ), (float)( c1.blue + c2.blue ) };
return color;
}
Color colorScale( double s, Color c )
{
Color color = { (float)( s * c.red ), (float)( s * c.green ), (float)( s * c.blue ) };
return color;
}
Color colorMultiplication( Color c1, Color c2 )
{
Color color = { (float)( c1.red * c2.red ), (float)( c1.green * c2.green ), (float)( c1.blue * c2.blue ) };
return color;
}
Color colorReflection( double s, Color l, Color m )
{
Color color = { (float)( s * ( l.red * m.red ) ), (float)( s * ( l.green * m.green ) ), (float)( s * ( l.blue * m.blue ) ) };
return color;
}
Color colorNormalize( Color c1 )
{
Color color= { (float)(c1.red/255.0), (float)(c1.green/255.0), (float)(c1.blue/255.0) };
return color;
}