forked from BB9z/RFKit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRFGeometry.h
92 lines (72 loc) · 2.27 KB
/
RFGeometry.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
/*!
RFGeometry
RFKit
Math and Graphics helper
Copyright (c) 2012-2014 BB9z
https://github.com/bb9z/RFKit
The MIT License (MIT)
http://www.opensource.org/licenses/mit-license.php
*/
#import "RFRuntime.h"
#ifndef _RFKit_RFGeometry_h_
#define _RFKit_RFGeometry_h_
#pragma mark - Const
#ifndef RFMathNotChange
# define RFMathNotChange CGFLOAT_MAX
#endif
extern const CGPoint CGPointNotChange;
extern const CGRect CGRectNotChange;
extern const CGSize CGSizeNotChange;
#pragma mark - Anchor
typedef NS_ENUM(NSInteger, RFResizeAnchor) {
RFResizeAnchorCenter = 0,
RFResizeAnchorTop,
RFResizeAnchorBottom,
RFResizeAnchorLeft,
RFResizeAnchorRight,
RFResizeAnchorTopLeft,
RFResizeAnchorTopRight,
RFResizeAnchorBottomLeft,
RFResizeAnchorBottomRight,
} ;
typedef NS_ENUM(NSInteger, RFAlignmentAnchor) {
RFAlignmentAnchorCenter = 0,
RFAlignmentAnchorTop,
RFAlignmentAnchorBottom,
RFAlignmentAnchorLeft,
RFAlignmentAnchorRight,
RFAlignmentAnchorTopLeft,
RFAlignmentAnchorTopRight,
RFAlignmentAnchorBottomLeft,
RFAlignmentAnchorBottomRight,
} ;
#pragma mark -
#pragma mark CGPoint
CGPoint CGPointMid (CGPoint a, CGPoint b);
float CGPointDistance (CGPoint a, CGPoint b);
CGPoint CGPointAtLineRatio(CGPoint start, CGPoint end, CGFloat ratio);
CGPoint CGPointOfRectCenter(CGRect a);
#pragma mark CGSize
CGSize CGSizeFromPoints(CGPoint a, CGPoint b);
CGSize CGSizeScaled (CGSize original, float scale);
#pragma mark CGRect
typedef NS_ENUM(NSInteger, RFCGRectChangeFlag) {
RFCGRectChangeX = 0,
RFCGRectChangeY,
RFCGRectChangeWidth,
RFCGRectChangeHeight
} ;
CGRect CGRectMakeWithPoints(CGPoint a, CGPoint b);
CGRect CGRectMakeWithCenterAndSize(CGPoint centerPoint, CGSize rectSize);
CGRect CGRectResize(CGRect original, CGSize newSize, RFResizeAnchor resizeAnchor);
// center not changed
CG_INLINE CGRect CGRectScaled(CGRect original, float scale) {
return CGRectResize(original, CGSizeMake(original.size.width*scale, original.size.height*scale), RFResizeAnchorCenter);
}
CGRect CGRectChange(CGRect original, RFCGRectChangeFlag flag, CGFloat newValue);
#pragma mark CGAngle
// radian measure
typedef float CGAngle;
CGAngle CGAngleFromPoints(CGPoint start, CGPoint end);
float CGAngleDegrees (CGAngle a);
#endif