summaryrefslogtreecommitdiff
path: root/platform/darwin/src/MGLLight.h
blob: f03afc0189cc2ad79ce2b6168bf1b9a1369df84d (plain)
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#import <CoreLocation/CoreLocation.h>

#import "MGLFoundation.h"
#import "MGLStyleValue.h"

NS_ASSUME_NONNULL_BEGIN


/** Options to specify extruded geometries are lit relative to the map or viewport. */
typedef NS_ENUM(NSUInteger, MGLLightAnchor) {
    /** The position of the light source is aligned to the rotation of the map. */
    MGLLightAnchorMap,
    /** The position of the light source is aligned to the rotation of the viewport. */
    MGLLightAnchorViewport
};

/**
 A structure containing information about the position of the light source
 relative to lit geometries.
 */
typedef struct MGLSphericalPosition {
    /** Distance from the center of the base of an object to its light. */
    CGFloat radial;
    /** Position of the light relative to 0° (0° when `MGLLight.anchor` is set to viewport corresponds
     to the top of the viewport, or 0° when `MGLLight.anchor` is set to map corresponds to due north,
     and degrees proceed clockwise). */
    CLLocationDirection azimuthal;
    /** Indicates the height of the light (from 0°, directly above, to 180°, directly below). */
    CLLocationDirection polar;
} MGLSphericalPosition;

/**
 Creates a new `MGLSphericalPosition` from the given radial, azimuthal, polar.
 
 @param radial The radial coordinate.
 @param azimuthal The azimuthal angle.
 @param polar The polar angle.
 
 @return Returns a `MGLSphericalPosition` struct containing the position attributes.
 */
NS_INLINE MGLSphericalPosition MGLSphericalPositionMake(CLLocationDistance radial, CLLocationDirection azimuthal, CLLocationDirection polar) {
    MGLSphericalPosition position;
    position.radial = radial;
    position.azimuthal = azimuthal;
    position.polar = polar;
    
    return position;
}

/**
 An `MGLLight` object represents the light source for extruded geometries in `MGLStyle`.
 */
MGL_EXPORT
@interface MGLLight : NSObject

/**
 `anchor` Whether extruded geometries are lit relative to the map or viewport.
 
 This property corresponds to the <a
 href="https://www.mapbox.com/mapbox-gl-js/style-spec/#light-anchor"><code>anchor</code></a>
 light property in the Mapbox Style Specification.
 */
@property (nonatomic) MGLStyleValue<NSValue *> *anchor;

/**
 Values describing animated transitions to `anchor` property.
 */
@property (nonatomic) MGLTransition anchorTransition;


/**
 Position of the light source relative to lit (extruded) geometries.
 
 This property corresponds to the <a
 href="https://www.mapbox.com/mapbox-gl-js/style-spec/#light-position"><code>position</code></a>
 light property in the Mapbox Style Specification.
 */
@property (nonatomic) MGLStyleValue<NSValue *> *position;

/**
 Values describing animated transitions to `position` property.
 */
@property (nonatomic) MGLTransition positionTransition;


#if TARGET_OS_IPHONE
/**
 Color tint for lighting extruded geometries.
 
 This property corresponds to the <a
 href="https://www.mapbox.com/mapbox-gl-js/style-spec/#light-color"><code>color</code></a>
 light property in the Mapbox Style Specification.
 */
@property (nonatomic) MGLStyleValue<UIColor *> *color;
#else

/**
 Color tint for lighting extruded geometries.
 */
@property (nonatomic) MGLStyleValue<NSColor *> *color;
#endif

/**
 Values describing animated transitions to `color` property.
 */
@property (nonatomic) MGLTransition colorTransition;


/**
 Intensity of lighting (on a scale from 0 to 1). Higher numbers will present as more extreme contrast.
 
 This property corresponds to the <a
 href="https://www.mapbox.com/mapbox-gl-js/style-spec/#light-intensity"><code>intensity</code></a>
 light property in the Mapbox Style Specification.
 */
@property(nonatomic) MGLStyleValue<NSNumber *> *intensity;

/**
 Values describing animated transitions to `intensity` property.
 */
@property (nonatomic) MGLTransition intensityTransition;

@end

NS_ASSUME_NONNULL_END