Latest 0.0.1
Homepage https://github.com/nebspetrovic/NPLumen
License MIT
Platforms ios 8.0, requires ARC
Authors

Version
License
Platform

About

Lumen is an iOS library for managing sources of light and objects that interact with them.

GitHub Logo
GitHub Logo

Example Usage

  // Create a delegate
  self.lumenGroupDebugger = [[NPLumenGroupDebugger alloc] init];

  // Create a lumen group
  self.lumenGroup = [[NPLumenGroup alloc] init];
  self.lumenGroup.delegate = self.lumenGroupShadowCaster;

  // Add some light sources and views
  [self.lumenGroup addSourceView:self.mySourceView];
  [self.lumenGroup addViews:[self.view1, self.view2]];

Overview

The key class in Lumen is NPLumenGroup. A lumen group contains light sources and objects (each of which must be UIView objects). The lumen group’s job is to calculate light ray vectors for each object based on the light sources. Each object gets assigned an appropriate light vector. When a vector is updated the lumen group tells its delegate.

Delegation

Any class that conforms to the NPLumenGroupDelegate protocol can act as the lumen group’s delegate. Here you have the opportunity to customize the behavior for each light vector applied to each view in a group.

For convenience (and demonstration purposes) I’ve included two delegates in this project: NPLumenGroupDebugger and NPLumenGroupShadowCaster. As their names suggest, the debugger overlays a line to indicate the vectors and the shadow caster adds a shadow to the view with the offset in the direction of the light vector. You can see an example of both of these in the animated gifs above.

To create your own delegate simply create a class and implement this method:

- (void)lumenGroup:(NPLumenGroup *)lumenGroup didUpdateLightVector:(CGPoint)lightVector forView:(UIView *)view {
  // Do something with the given view and vector (vectors are normalized).
}

Requirements

Lumen requires iOS 8.0 and above.

Installation

NPLumen is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod "NPLumen"

Author

Nebojsa Petrovic, [email protected]

License

NPLumen is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "NPLumen",
    "version": "0.0.1",
    "summary": "Light source management",
    "description": "                       NPLumen is an iOS library that allows you to treatn                       UIViews as either light sources or objects which respondn                       to the sources. For example you can have one view cast an                       relative shadow on other views.n",
    "homepage": "https://github.com/nebspetrovic/NPLumen",
    "license": "MIT",
    "authors": {
        "Nebojsa Petrovic": "[email protected]"
    },
    "source": {
        "git": "https://github.com/nebspetrovic/NPLumen.git",
        "tag": "0.0.1"
    },
    "social_media_url": "https://twitter.com/nebsp",
    "platforms": {
        "ios": "8.0"
    },
    "requires_arc": true,
    "source_files": "Pod/Classes/**/*.{h,m}",
    "resource_bundles": {
        "NPCricket": [
            "Pod/Classes/**/*.xib"
        ]
    },
    "public_header_files": "Pod/Classes/**/*.h"
}

Pin It on Pinterest

Share This