-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTLMapFrameLayer.m
44 lines (38 loc) · 1.47 KB
/
TLMapFrameLayer.m
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
//
// TLMapFrameLayer.m
// Mercatalog
//
// Created by Nathan Vander Wilt on 8/5/08.
// Copyright 2008 Calf Trail Software, LLC. All rights reserved.
//
#import "TLMapFrameLayer.h"
#import "TLCocoaToolbag.h"
#import "TLProjectionInfo.h"
#import "TLProjectionGeometry.h"
#import "TLProjectedDrawing.h"
@implementation TLMapFrameLayer
- (void)drawInContext:(CGContextRef)ctx withInfo:(id < TLMapInfo >)mapInfo {
// draw paper-white background
CGRect drawableBox = CGContextGetClipBoundingBox(ctx);
CGContextAddRect(ctx, drawableBox);
CGColorRef backgroundColor = TLCGColorCreateGenericHSB(0.15f, 0.02f, 0.97f, 1.0f);
CGContextSetFillColorWithColor(ctx, backgroundColor);
CGColorRelease(backgroundColor);
CGContextFillPath(ctx);
// draw range frame
CGFloat significantDistance = TLSizeGetAverageWidth([mapInfo significantVisualSize]);
TLMultiPolygonRef projectionRange = TLProjectionInfoCreateRange([mapInfo projection], significantDistance);
if (projectionRange) {
CGPathRef rangePath = TLCGPathCreateFromMultiPolygon(projectionRange, YES, significantDistance);
TLMultiPolygonRelease(projectionRange);
CGContextAddPath(ctx, rangePath);
CGPathRelease(rangePath);
CGColorRef frameColor = TLCGColorCreateGenericHSB(0.0f, 1.0f, 0.0f, 0.7f);
CGContextSetStrokeColorWithColor(ctx, frameColor);
CGColorRelease(frameColor);
CGFloat mmSize = TLSizeGetAverageWidth([mapInfo millimeterSize]);
CGContextSetLineWidth(ctx, 0.5f * mmSize);
CGContextStrokePath(ctx);
}
}
@end