forked from core-plot/core-plot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCPTPlatformSpecificFunctions.m
More file actions
38 lines (27 loc) · 961 Bytes
/
CPTPlatformSpecificFunctions.m
File metadata and controls
38 lines (27 loc) · 961 Bytes
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
#import "CPTPlatformSpecificFunctions.h"
#import "CPTExceptions.h"
#pragma mark -
#pragma mark Context management
void CPTPushCGContext(__nonnull CGContextRef newContext)
{
UIGraphicsPushContext(newContext);
}
void CPTPopCGContext(void)
{
UIGraphicsPopContext();
}
#pragma mark -
#pragma mark Debugging
CPTNativeImage * __nonnull CPTQuickLookImage(CGRect rect, __nonnull CPTQuickLookImageBlock renderBlock)
{
UIGraphicsBeginImageContextWithOptions(rect.size, YES, 1.0);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextTranslateCTM(context, 0, rect.size.height);
CGContextScaleCTM(context, 1.0, -1.0);
CGContextSetRGBFillColor(context, CPTFloat(0xf6 / 255.0), CPTFloat(0xf5 / 255.0), CPTFloat(0xf6 / 255.0), 1.0);
CGContextFillRect(context, rect);
renderBlock(context, 1.0, rect);
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}