forked from overtake/telegram
-
Notifications
You must be signed in to change notification settings - Fork 6
/
POPCGUtils.h
executable file
·107 lines (83 loc) · 2.28 KB
/
POPCGUtils.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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/**
Copyright (c) 2014-present, Facebook, Inc.
All rights reserved.
This source code is licensed under the BSD-style license found in the
LICENSE file in the root directory of this source tree. An additional grant
of patent rights can be found in the PATENTS file in the same directory.
*/
#import <CoreGraphics/CoreGraphics.h>
#if TARGET_OS_IPHONE
#import <UIKit/UIKit.h>
#endif
#import "POPDefines.h"
#if TARGET_OS_IPHONE
@class UIColor;
#endif
POP_EXTERN_C_BEGIN
NS_INLINE CGPoint values_to_point(const CGFloat values[])
{
return CGPointMake(values[0], values[1]);
}
NS_INLINE CGSize values_to_size(const CGFloat values[])
{
return CGSizeMake(values[0], values[1]);
}
NS_INLINE CGRect values_to_rect(const CGFloat values[])
{
return CGRectMake(values[0], values[1], values[2], values[3]);
}
#if TARGET_OS_IPHONE
NS_INLINE UIEdgeInsets values_to_edge_insets(const CGFloat values[])
{
return UIEdgeInsetsMake(values[0], values[1], values[2], values[3]);
}
#endif
NS_INLINE void values_from_point(CGFloat values[], CGPoint p)
{
values[0] = p.x;
values[1] = p.y;
}
NS_INLINE void values_from_size(CGFloat values[], CGSize s)
{
values[0] = s.width;
values[1] = s.height;
}
NS_INLINE void values_from_rect(CGFloat values[], CGRect r)
{
values[0] = r.origin.x;
values[1] = r.origin.y;
values[2] = r.size.width;
values[3] = r.size.height;
}
#if TARGET_OS_IPHONE
NS_INLINE void values_from_edge_insets(CGFloat values[], UIEdgeInsets i)
{
values[0] = i.top;
values[1] = i.left;
values[2] = i.bottom;
values[3] = i.right;
}
#endif
/**
Takes a CGColorRef and converts it into RGBA components, if necessary.
*/
extern void POPCGColorGetRGBAComponents(CGColorRef color, CGFloat components[]);
/**
Takes RGBA components and returns a CGColorRef.
*/
extern CGColorRef POPCGColorRGBACreate(const CGFloat components[]) CF_RETURNS_RETAINED;
/**
Takes a color reference and returns a CGColor.
*/
extern CGColorRef POPCGColorWithColor(id color);
#if TARGET_OS_IPHONE
/**
Takes a UIColor and converts it into RGBA components, if necessary.
*/
extern void POPUIColorGetRGBAComponents(UIColor *color, CGFloat components[]);
/**
Takes RGBA components and returns a UIColor.
*/
extern UIColor *POPUIColorRGBACreate(const CGFloat components[]) NS_RETURNS_RETAINED;
#endif
POP_EXTERN_C_END