14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#include "config.h"
#import "OFColor.h"
#import "OFInvalidArgumentException.h"
@implementation OFColor
+ (instancetype)colorWithRed: (float)red
green: (float)green
blue: (float)blue
alpha: (float)alpha
{
return [[[self alloc] initWithRed: red
green: green
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
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
|
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#include "config.h"
#import "OFColor.h"
#import "once.h"
#import "OFInvalidArgumentException.h"
@implementation OFColor
#define PREDEFINED_COLOR(name, r, g, b) \
static OFColor *name = nil; \
\
static void \
initPredefinedColor_##name(void) \
{ \
name = [[OFColor alloc] initWithRed: r \
green: g \
blue: b \
alpha: 1]; \
} \
\
+ (OFColor *)name \
{ \
static of_once_t onceControl = OF_ONCE_INIT; \
of_once(&onceControl, initPredefinedColor_##name); \
\
return name; \
}
PREDEFINED_COLOR(black, 0.00, 0.00, 0.00)
PREDEFINED_COLOR(silver, 0.75, 0.75, 0.75)
PREDEFINED_COLOR(grey, 0.50, 0.50, 0.50)
PREDEFINED_COLOR(white, 1.00, 1.00, 1.00)
PREDEFINED_COLOR(maroon, 0.50, 0.00, 0.00)
PREDEFINED_COLOR(red, 1.00, 0.00, 0.00)
PREDEFINED_COLOR(purple, 0.50, 0.00, 0.50)
PREDEFINED_COLOR(fuchsia, 1.00, 0.00, 1.00)
PREDEFINED_COLOR(green, 0.00, 0.50, 0.00)
PREDEFINED_COLOR(lime, 0.00, 1.00, 0.00)
PREDEFINED_COLOR(olive, 0.50, 0.50, 0.00)
PREDEFINED_COLOR(yellow, 1.00, 1.00, 0.00)
PREDEFINED_COLOR(navy, 0.00, 0.00, 0.50)
PREDEFINED_COLOR(blue, 0.00, 0.00, 1.00)
PREDEFINED_COLOR(teal, 0.00, 0.50, 0.50)
PREDEFINED_COLOR(aqua, 0.00, 1.00, 1.00)
+ (instancetype)colorWithRed: (float)red
green: (float)green
blue: (float)blue
alpha: (float)alpha
{
return [[[self alloc] initWithRed: red
green: green
|