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
|
#import "OFOnce.h"
#import "OFString.h"
#import "OFTaggedPointerColor.h"
@interface OFColorSingleton: OFConcreteColor
@end
@interface OFColorPlaceholder: OFColor
@end
static struct {
Class isa;
} placeholder;
#ifdef OF_OBJFW_RUNTIME
static const float allowedImprecision = 0.0000001;
#endif
@implementation OFColorPlaceholder
- (instancetype)initWithRed: (float)red
green: (float)green
blue: (float)blue
alpha: (float)alpha
{
#ifdef OF_OBJFW_RUNTIME
uint8_t redInt = nearbyintf(red * 255);
|
|
|
|
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
|
#import "OFOnce.h"
#import "OFString.h"
#import "OFTaggedPointerColor.h"
@interface OFColorSingleton: OFConcreteColor
@end
@interface OFPlaceholderColor: OFColor
@end
static struct {
Class isa;
} placeholder;
#ifdef OF_OBJFW_RUNTIME
static const float allowedImprecision = 0.0000001;
#endif
@implementation OFPlaceholderColor
- (instancetype)initWithRed: (float)red
green: (float)green
blue: (float)blue
alpha: (float)alpha
{
#ifdef OF_OBJFW_RUNTIME
uint8_t redInt = nearbyintf(red * 255);
|
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
OF_SINGLETON_METHODS
@end
@implementation OFColor
+ (void)initialize
{
if (self == [OFColor class])
object_setClass((id)&placeholder, [OFColorPlaceholder class]);
}
+ (instancetype)alloc
{
if (self == [OFColor class])
return (id)&placeholder;
|
|
|
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
OF_SINGLETON_METHODS
@end
@implementation OFColor
+ (void)initialize
{
if (self == [OFColor class])
object_setClass((id)&placeholder, [OFPlaceholderColor class]);
}
+ (instancetype)alloc
{
if (self == [OFColor class])
return (id)&placeholder;
|