<commit_before># Ambient Light Mapbox GL iOS Demo

A [Mapbox GL for iOS](https://github.com/mapbox/mapbox-gl-native) demo app that demonstrates ambient light-based map styling.

![Would be nice to live in London, wouldn't it.](https://cloud.githubusercontent.com/assets/1198851/7792257/631d2a12-0264-11e5-82c8-0d8a942adaf8.png)

## Getting started

1.  Clone or [download](https://github.com/friedbunny/ambient-light/archive/master.zip) this repository
1. Run `pod install` to download the Mapbox GL library via [Cocoapods](https://cocoapods.org)
1. Open `ambient-light.xcworkspace` in Xcode
1. Insert your [Mapbox access token](https://www.mapbox.com/developers/api/#access-tokens) into Map View’s Attributes Inspector panel in Interface Builder: ![Interface Builder has lots of names for things that you'll never know about](https://cloud.githubusercontent.com/assets/1198851/7789419/5e5c002a-0214-11e5-8315-6617fb3d47c5.png)
1. Build amazing cartographic things

## Detecting ambient light

This is a bit of a lie: Apple does not expose any direct ambient light sensing API to developers, so **this demo uses screen brightness as a proxy**.

This relies on the user having auto brightness enabled, which isn’t always a given (and there’s no easy way to detect if that’s on, either).

Generally this technique works well and is the same that’s used in [Tweetbot](http://tapbots.com/tweetbot/).

## How the UI works

The slider controls the screen brightness threshold at which the map will change styles — e.g., farther left will switch to the dark style at a lower screen brightness.

My preferred threshold is about 35%, or somewhat left of center.

Current brightness is indicated by a vertical line on top of the slider bar.

![Annoying gif demo](https://cloud.githubusercontent.com/assets/1198851/7792704/71965206-026b-11e5-8388-5e2d0a6cb5f3.gif)

## Does not work in simulator<commit_msg>Explain AppDelegate access token setting<commit_after># Ambient Light Mapbox GL iOS Demo

A [Mapbox GL for iOS](https://github.com/mapbox/mapbox-gl-native) demo app that demonstrates ambient light-based map styling.

![Would be nice to live in London, wouldn't it.](https://cloud.githubusercontent.com/assets/1198851/7792257/631d2a12-0264-11e5-82c8-0d8a942adaf8.png)

## Getting started

1.  Clone or [download](https://github.com/friedbunny/ambient-light/archive/master.zip) this repository
1. Run `pod install` to download the Mapbox GL library via [Cocoapods](https://cocoapods.org)
1. Open `ambient-light.xcworkspace` in Xcode
1. Insert your [Mapbox access token](https://www.mapbox.com/developers/api/#access-tokens) in [`AppDelegate.m`](https://github.com/friedbunny/ambient-light/blob/bc26fe94c05968c33eb5926c3b9148516ebebf96/ambient-light/AppDelegate.m#L21)
1. Build amazing cartographic things

## Detecting ambient light

This is a bit of a lie: Apple does not expose any direct ambient light sensing API to developers, so **this demo uses screen brightness as a proxy**.

This relies on the user having auto brightness enabled, which isn’t always a given (and there’s no easy way to detect if that’s on, either).

Generally this technique works well and is the same that’s used in [Tweetbot](http://tapbots.com/tweetbot/).

## How the UI works

The slider controls the screen brightness threshold at which the map will change styles — e.g., farther left will switch to the dark style at a lower screen brightness.

My preferred threshold is about 35%, or somewhat left of center.

Current brightness is indicated by a vertical line on top of the slider bar.

![Annoying gif demo](https://cloud.githubusercontent.com/assets/1198851/7792704/71965206-026b-11e5-8388-5e2d0a6cb5f3.gif)

## Does not work in simulator
{'fraction_non_alphanumeric': 0.09225389994620764, 'fraction_numerical': 0.06105433028509952, 'mean_word_length': 4.783825816485225, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 14, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4057164', 'n_tokens_mistral': 1288, 'n_tokens_neox': 1137, 'n_words': 427}