Skip to content

Commit 5a76f09

Browse files
committed
First Commit
1 parent ccc63b8 commit 5a76f09

File tree

14 files changed

+728
-3
lines changed

14 files changed

+728
-3
lines changed

ASFHeatMap.xcodeproj/project.pbxproj

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,42 @@
88

99
/* Begin PBXBuildFile section */
1010
65FF17001E79D20C0083328D /* ASFHeatMap.h in Headers */ = {isa = PBXBuildFile; fileRef = 65FF16FE1E79D20C0083328D /* ASFHeatMap.h */; settings = {ATTRIBUTES = (Public, ); }; };
11+
65FF17081E79D23E0083328D /* Heatmap.h in Headers */ = {isa = PBXBuildFile; fileRef = 65FF17061E79D23E0083328D /* Heatmap.h */; settings = {ATTRIBUTES = (Public, ); }; };
12+
65FF17091E79D23E0083328D /* Heatmap.m in Sources */ = {isa = PBXBuildFile; fileRef = 65FF17071E79D23E0083328D /* Heatmap.m */; };
13+
65FF170D1E79D2880083328D /* ColorProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = 65FF170B1E79D2880083328D /* ColorProvider.h */; settings = {ATTRIBUTES = (Public, ); }; };
14+
65FF170E1E79D2880083328D /* ColorProvider.m in Sources */ = {isa = PBXBuildFile; fileRef = 65FF170C1E79D2880083328D /* ColorProvider.m */; };
15+
65FF17111E79D3870083328D /* DiffColorProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = 65FF170F1E79D3870083328D /* DiffColorProvider.h */; settings = {ATTRIBUTES = (Public, ); }; };
16+
65FF17121E79D3870083328D /* DiffColorProvider.m in Sources */ = {isa = PBXBuildFile; fileRef = 65FF17101E79D3870083328D /* DiffColorProvider.m */; };
17+
65FF17151E79D4260083328D /* HeatMapRenderer.h in Headers */ = {isa = PBXBuildFile; fileRef = 65FF17131E79D4260083328D /* HeatMapRenderer.h */; settings = {ATTRIBUTES = (Public, ); }; };
18+
65FF17161E79D4260083328D /* HeatMapRenderer.m in Sources */ = {isa = PBXBuildFile; fileRef = 65FF17141E79D4260083328D /* HeatMapRenderer.m */; };
19+
65FF17191E79D51D0083328D /* DiffHeatMap.h in Headers */ = {isa = PBXBuildFile; fileRef = 65FF17171E79D51D0083328D /* DiffHeatMap.h */; settings = {ATTRIBUTES = (Public, ); }; };
20+
65FF171A1E79D51D0083328D /* DiffHeatMap.m in Sources */ = {isa = PBXBuildFile; fileRef = 65FF17181E79D51D0083328D /* DiffHeatMap.m */; };
21+
65FF171F1E79D9DD0083328D /* MapKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 65FF171E1E79D9DD0083328D /* MapKit.framework */; };
1122
/* End PBXBuildFile section */
1223

1324
/* Begin PBXFileReference section */
1425
65FF16FB1E79D20C0083328D /* ASFHeatMap.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = ASFHeatMap.framework; sourceTree = BUILT_PRODUCTS_DIR; };
1526
65FF16FE1E79D20C0083328D /* ASFHeatMap.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ASFHeatMap.h; sourceTree = "<group>"; };
1627
65FF16FF1E79D20C0083328D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
28+
65FF17061E79D23E0083328D /* Heatmap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Heatmap.h; sourceTree = "<group>"; };
29+
65FF17071E79D23E0083328D /* Heatmap.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Heatmap.m; sourceTree = "<group>"; };
30+
65FF170B1E79D2880083328D /* ColorProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ColorProvider.h; sourceTree = "<group>"; };
31+
65FF170C1E79D2880083328D /* ColorProvider.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ColorProvider.m; sourceTree = "<group>"; };
32+
65FF170F1E79D3870083328D /* DiffColorProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DiffColorProvider.h; sourceTree = "<group>"; };
33+
65FF17101E79D3870083328D /* DiffColorProvider.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DiffColorProvider.m; sourceTree = "<group>"; };
34+
65FF17131E79D4260083328D /* HeatMapRenderer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HeatMapRenderer.h; sourceTree = "<group>"; };
35+
65FF17141E79D4260083328D /* HeatMapRenderer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HeatMapRenderer.m; sourceTree = "<group>"; };
36+
65FF17171E79D51D0083328D /* DiffHeatMap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DiffHeatMap.h; sourceTree = "<group>"; };
37+
65FF17181E79D51D0083328D /* DiffHeatMap.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DiffHeatMap.m; sourceTree = "<group>"; };
38+
65FF171E1E79D9DD0083328D /* MapKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MapKit.framework; path = System/Library/Frameworks/MapKit.framework; sourceTree = SDKROOT; };
1739
/* End PBXFileReference section */
1840

1941
/* Begin PBXFrameworksBuildPhase section */
2042
65FF16F71E79D20C0083328D /* Frameworks */ = {
2143
isa = PBXFrameworksBuildPhase;
2244
buildActionMask = 2147483647;
2345
files = (
46+
65FF171F1E79D9DD0083328D /* MapKit.framework in Frameworks */,
2447
);
2548
runOnlyForDeploymentPostprocessing = 0;
2649
};
@@ -32,6 +55,7 @@
3255
children = (
3356
65FF16FD1E79D20C0083328D /* ASFHeatMap */,
3457
65FF16FC1E79D20C0083328D /* Products */,
58+
65FF171D1E79D9DD0083328D /* Frameworks */,
3559
);
3660
sourceTree = "<group>";
3761
};
@@ -46,20 +70,51 @@
4670
65FF16FD1E79D20C0083328D /* ASFHeatMap */ = {
4771
isa = PBXGroup;
4872
children = (
73+
65FF170A1E79D26E0083328D /* ColorProvider */,
4974
65FF16FE1E79D20C0083328D /* ASFHeatMap.h */,
5075
65FF16FF1E79D20C0083328D /* Info.plist */,
76+
65FF17061E79D23E0083328D /* Heatmap.h */,
77+
65FF17071E79D23E0083328D /* Heatmap.m */,
78+
65FF17131E79D4260083328D /* HeatMapRenderer.h */,
79+
65FF17141E79D4260083328D /* HeatMapRenderer.m */,
80+
65FF17171E79D51D0083328D /* DiffHeatMap.h */,
81+
65FF17181E79D51D0083328D /* DiffHeatMap.m */,
5182
);
5283
path = ASFHeatMap;
5384
sourceTree = "<group>";
5485
};
86+
65FF170A1E79D26E0083328D /* ColorProvider */ = {
87+
isa = PBXGroup;
88+
children = (
89+
65FF170B1E79D2880083328D /* ColorProvider.h */,
90+
65FF170C1E79D2880083328D /* ColorProvider.m */,
91+
65FF170F1E79D3870083328D /* DiffColorProvider.h */,
92+
65FF17101E79D3870083328D /* DiffColorProvider.m */,
93+
);
94+
name = ColorProvider;
95+
sourceTree = "<group>";
96+
};
97+
65FF171D1E79D9DD0083328D /* Frameworks */ = {
98+
isa = PBXGroup;
99+
children = (
100+
65FF171E1E79D9DD0083328D /* MapKit.framework */,
101+
);
102+
name = Frameworks;
103+
sourceTree = "<group>";
104+
};
55105
/* End PBXGroup section */
56106

57107
/* Begin PBXHeadersBuildPhase section */
58108
65FF16F81E79D20C0083328D /* Headers */ = {
59109
isa = PBXHeadersBuildPhase;
60110
buildActionMask = 2147483647;
61111
files = (
112+
65FF17111E79D3870083328D /* DiffColorProvider.h in Headers */,
62113
65FF17001E79D20C0083328D /* ASFHeatMap.h in Headers */,
114+
65FF17191E79D51D0083328D /* DiffHeatMap.h in Headers */,
115+
65FF17081E79D23E0083328D /* Heatmap.h in Headers */,
116+
65FF170D1E79D2880083328D /* ColorProvider.h in Headers */,
117+
65FF17151E79D4260083328D /* HeatMapRenderer.h in Headers */,
63118
);
64119
runOnlyForDeploymentPostprocessing = 0;
65120
};
@@ -132,6 +187,11 @@
132187
isa = PBXSourcesBuildPhase;
133188
buildActionMask = 2147483647;
134189
files = (
190+
65FF171A1E79D51D0083328D /* DiffHeatMap.m in Sources */,
191+
65FF170E1E79D2880083328D /* ColorProvider.m in Sources */,
192+
65FF17091E79D23E0083328D /* Heatmap.m in Sources */,
193+
65FF17121E79D3870083328D /* DiffColorProvider.m in Sources */,
194+
65FF17161E79D4260083328D /* HeatMapRenderer.m in Sources */,
135195
);
136196
runOnlyForDeploymentPostprocessing = 0;
137197
};
@@ -181,7 +241,7 @@
181241
GCC_WARN_UNUSED_VARIABLE = YES;
182242
IPHONEOS_DEPLOYMENT_TARGET = 10.2;
183243
MTL_ENABLE_DEBUG_INFO = YES;
184-
ONLY_ACTIVE_ARCH = YES;
244+
ONLY_ACTIVE_ARCH = NO;
185245
SDKROOT = iphoneos;
186246
TARGETED_DEVICE_FAMILY = "1,2";
187247
VERSIONING_SYSTEM = "apple-generic";

ASFHeatMap.xcodeproj/xcuserdata/andre.xcuserdatad/xcschemes/ASFHeatMap.xcscheme renamed to ASFHeatMap.xcodeproj/xcshareddata/xcschemes/ASFHeatMap.xcscheme

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,22 @@
55
<BuildAction
66
parallelizeBuildables = "YES"
77
buildImplicitDependencies = "YES">
8+
<BuildActionEntries>
9+
<BuildActionEntry
10+
buildForTesting = "YES"
11+
buildForRunning = "YES"
12+
buildForProfiling = "YES"
13+
buildForArchiving = "YES"
14+
buildForAnalyzing = "YES">
15+
<BuildableReference
16+
BuildableIdentifier = "primary"
17+
BlueprintIdentifier = "65FF16FA1E79D20C0083328D"
18+
BuildableName = "ASFHeatMap.framework"
19+
BlueprintName = "ASFHeatMap"
20+
ReferencedContainer = "container:ASFHeatMap.xcodeproj">
21+
</BuildableReference>
22+
</BuildActionEntry>
23+
</BuildActionEntries>
824
</BuildAction>
925
<TestAction
1026
buildConfiguration = "Debug"
@@ -26,6 +42,15 @@
2642
debugDocumentVersioning = "YES"
2743
debugServiceExtension = "internal"
2844
allowLocationSimulation = "YES">
45+
<MacroExpansion>
46+
<BuildableReference
47+
BuildableIdentifier = "primary"
48+
BlueprintIdentifier = "65FF16FA1E79D20C0083328D"
49+
BuildableName = "ASFHeatMap.framework"
50+
BlueprintName = "ASFHeatMap"
51+
ReferencedContainer = "container:ASFHeatMap.xcodeproj">
52+
</BuildableReference>
53+
</MacroExpansion>
2954
<AdditionalOptions>
3055
</AdditionalOptions>
3156
</LaunchAction>
@@ -35,6 +60,15 @@
3560
savedToolIdentifier = ""
3661
useCustomWorkingDirectory = "NO"
3762
debugDocumentVersioning = "YES">
63+
<MacroExpansion>
64+
<BuildableReference
65+
BuildableIdentifier = "primary"
66+
BlueprintIdentifier = "65FF16FA1E79D20C0083328D"
67+
BuildableName = "ASFHeatMap.framework"
68+
BlueprintName = "ASFHeatMap"
69+
ReferencedContainer = "container:ASFHeatMap.xcodeproj">
70+
</BuildableReference>
71+
</MacroExpansion>
3872
</ProfileAction>
3973
<AnalyzeAction
4074
buildConfiguration = "Debug">

ASFHeatMap.xcodeproj/xcuserdata/andre.xcuserdatad/xcschemes/xcschememanagement.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<dict>
55
<key>SchemeUserState</key>
66
<dict>
7-
<key>ASFHeatMap.xcscheme</key>
7+
<key>ASFHeatMap.xcscheme_^#shared#^_</key>
88
<dict>
99
<key>orderHint</key>
1010
<integer>0</integer>

ASFHeatMap/ASFHeatMap.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,8 @@ FOUNDATION_EXPORT const unsigned char ASFHeatMapVersionString[];
1616

1717
// In this header, you should import all the public headers of your framework using statements like #import <ASFHeatMap/PublicHeader.h>
1818

19-
19+
#import "Heatmap.h"
20+
#import "HeatMapRenderer.h"
21+
#import "DiffHeatMap.h"
22+
#import "DiffColorProvider.h"
23+
#import "ColorProvider.h"

ASFHeatMap/ColorProvider.h

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
//
2+
// ColorProvider.h
3+
// ASFHeatMap
4+
//
5+
// Created by Andre Santana Ferreira on 15/03/17.
6+
// Copyright © 2017 Andre. All rights reserved.
7+
//
8+
9+
#import <Foundation/Foundation.h>
10+
#import <UIKit/UIKit.h>
11+
12+
// These affect the transparency of the heatmap
13+
// Colder areas will be more transparent
14+
// Currently the alpha is a two piece linear function of the value
15+
// Play with the pivot point and max alpha to affect the look of the heatmap
16+
17+
// This number should be between 0 and 1
18+
static const CGFloat kSBAlphaPivotX = 0.333;
19+
20+
// This number should be between 0 and MAX_ALPHA
21+
static const CGFloat kSBAlphaPivotY = 0.5;
22+
23+
// This number should be between 0 and 1
24+
static const CGFloat kSBMaxAlpha = 0.85;
25+
26+
@interface ColorProvider : NSObject
27+
28+
- (void)colorForValue:(double)value
29+
red:(CGFloat *)red
30+
green:(CGFloat *)green
31+
blue:(CGFloat *)blue
32+
alpha:(CGFloat *)alpha;
33+
@end

ASFHeatMap/ColorProvider.m

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
//
2+
// ColorProvider.m
3+
// ASFHeatMap
4+
//
5+
// Created by Andre Santana Ferreira on 15/03/17.
6+
// Copyright © 2017 Andre. All rights reserved.
7+
//
8+
9+
#import "ColorProvider.h"
10+
11+
@implementation ColorProvider
12+
13+
- (void)colorForValue:(double)value
14+
red:(CGFloat *)red
15+
green:(CGFloat *)green
16+
blue:(CGFloat *)blue
17+
alpha:(CGFloat *)alpha
18+
{
19+
static int maxVal = 255;
20+
if (value > 1) {
21+
value = 1;
22+
}
23+
24+
value = sqrt(value);
25+
26+
if (value < kSBAlphaPivotY) {
27+
*alpha = value * kSBAlphaPivotY / kSBAlphaPivotX;
28+
} else {
29+
*alpha = kSBAlphaPivotY + ((kSBMaxAlpha - kSBAlphaPivotY) / (1 - kSBAlphaPivotX)) * (value - kSBAlphaPivotX);
30+
}
31+
32+
//formula converts a number from 0 to 1.0 to an rgb color.
33+
//uses MATLAB/Octave colorbar code
34+
if (value <= 0) {
35+
*red = *green = *blue = *alpha = 0;
36+
} else if (value < 0.125) {
37+
*red = *green = 0;
38+
*blue = 4 * (value + 0.125);
39+
} else if (value < 0.375) {
40+
*red = 0;
41+
*green = 4 * (value - 0.125);
42+
*blue = 1;
43+
} else if (value < 0.625) {
44+
*red = 4 * (value - 0.375);
45+
*green = 1;
46+
*blue = 1 - 4 * (value - 0.375);
47+
} else if (value < 0.875) {
48+
*red = 1;
49+
*green = 1 - 4 * (value - 0.625);
50+
*blue = 0;
51+
} else {
52+
*red = MAX(1 - 4 * (value - 0.875), 0.5);
53+
*green = *blue = 0;
54+
}
55+
56+
*alpha *= maxVal;
57+
*blue *= *alpha;
58+
*green *= *alpha;
59+
*red *= *alpha;
60+
}
61+
62+
@end

ASFHeatMap/DiffColorProvider.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//
2+
// DiffColorProvider.h
3+
// ASFHeatMap
4+
//
5+
// Created by Andre Santana Ferreira on 15/03/17.
6+
// Copyright © 2017 Andre. All rights reserved.
7+
//
8+
9+
#import <Foundation/Foundation.h>
10+
#import <UIKit/UIKit.h>
11+
#import "ColorProvider.h"
12+
13+
@interface DiffColorProvider : ColorProvider
14+
15+
@end

ASFHeatMap/DiffColorProvider.m

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
//
2+
// DiffColorProvider.m
3+
// ASFHeatMap
4+
//
5+
// Created by Andre Santana Ferreira on 15/03/17.
6+
// Copyright © 2017 Andre. All rights reserved.
7+
//
8+
9+
#import "DiffColorProvider.h"
10+
11+
@implementation DiffColorProvider
12+
13+
- (void)colorForValue:(double)value
14+
red:(CGFloat *)red
15+
green:(CGFloat *)green
16+
blue:(CGFloat *)blue
17+
alpha:(CGFloat *)alpha
18+
{
19+
static int maxVal = 255;
20+
21+
if (value == 0) {
22+
return;
23+
}
24+
25+
BOOL isNegative = value < 0;
26+
value = sqrt(MIN(ABS(value), 1));
27+
if (value < kSBAlphaPivotY) {
28+
*alpha = value * kSBAlphaPivotY / kSBAlphaPivotX;
29+
} else {
30+
*alpha = kSBAlphaPivotY + ((kSBMaxAlpha - kSBAlphaPivotY) / (1 - kSBAlphaPivotX)) * (value - kSBAlphaPivotX);
31+
}
32+
33+
if (isNegative) {
34+
*red = 0;
35+
if (value <= 0) {
36+
*green = *blue = *alpha = 0;
37+
} else if (value < 0.125) {
38+
*green = 0;
39+
*blue = 2 * (value + 0.125);
40+
} else if (value < 0.375) {
41+
*blue = 2 * (value + 0.125);
42+
*green = 4 * (value - 0.125);
43+
} else if (value < 0.625) {
44+
*blue = 4 * (value - 0.375);
45+
*green = 1;
46+
} else if (value < 0.875) {
47+
*blue = 1;
48+
*green = 1 - 4 * (value - 0.625);
49+
} else {
50+
*blue = MAX(1 - 4 * (value - 0.875), 0.5);
51+
*green = 0;
52+
}
53+
} else {
54+
*blue = 0;
55+
if (value <= 0) {
56+
*red = *green = *alpha = 0;
57+
} else if (value < 0.125) {
58+
*green = value;
59+
*red = (value);
60+
} else if (value < 0.375) {
61+
*red = (value + 0.125);
62+
*green = value;
63+
} else if (value < 0.625) {
64+
*red = (value + 0.125);
65+
*green = value;
66+
} else if (value < 0.875) {
67+
*red = (value + 0.125);
68+
*green = 1 - 4 * (value - 0.625);
69+
} else {
70+
*green = 0;
71+
*red = MAX(1 - 4 * (value - 0.875), 0.5);
72+
}
73+
}
74+
75+
*alpha *= maxVal;
76+
*blue *= *alpha;
77+
*green *= *alpha;
78+
*red *= *alpha;
79+
}
80+
81+
@end

0 commit comments

Comments
 (0)