diff options
author | Fabian Guerra Soto <fabian.guerra@mapbox.com> | 2017-05-23 10:59:24 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-05-23 10:59:24 -0400 |
commit | e52249c17fb529c476569b6d7ef141be1bff7d7f (patch) | |
tree | 634de63e3cc541aa9dedf1bdf9f453f65d52ee9e /platform/darwin/src/MGLLight.h | |
parent | a19fd817300abf00b81cba5765fda62c48057efa (diff) | |
download | qtlocation-mapboxgl-e52249c17fb529c476569b6d7ef141be1bff7d7f.tar.gz |
[ios, macos] Light property implementation in MGLStyle (#9043)
* [ios, macos] Add MGLLight to MGLStyle
* [ios, macos] Implement Objc bindings for Light object
* [ios, macos] Remove rawLight from MGLLight and re-implement it as value class
* [ios, macos] Fix build on macos
* [ios, macos] Add MGLLight documentation, Move MGLLightPosition to MGLLight
* [ios, macos] Add MGLLight tests.
* [ios, macos] Update changelogs
* [ios, macos] Fix misspelling
* [ios, macos] Fix MGLLightAnchor enum property names
* [ios, macos] Update documentation. Improve varialble naming.
* [ios, macos] Rename MGLLightPosition to MGLSphericalPosition
* [ios, macos] Update data types of MGLSphericalPosition
Diffstat (limited to 'platform/darwin/src/MGLLight.h')
-rw-r--r-- | platform/darwin/src/MGLLight.h | 125 |
1 files changed, 125 insertions, 0 deletions
diff --git a/platform/darwin/src/MGLLight.h b/platform/darwin/src/MGLLight.h new file mode 100644 index 0000000000..d9a22d60fa --- /dev/null +++ b/platform/darwin/src/MGLLight.h @@ -0,0 +1,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. */ + CLLocationDistance 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) MGLLightAnchor 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 positionTransiton; + + +#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 colorTransiton; + + +/** + 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 |