Inherits from NSObject
Declared in AKImageRenderer.h
AKImageRenderer.m

Overview

The AKImageRenderer class is the workhorse of AmazeKit where image rendering actually happens. Each image renderer maintains an array of image effects that are rendered in sequence, thereby producing a final image.

Tasks

Customizing Rendering

Performing Rendering

Caching

  • – renderedImages

    Generates a dictionary representing previously-rendered images, useful for generating pre-rendered images at app startup. The keys are the sizes turned into a string, and the values are sets containing the options dictionaries passed for that size, or an NSNull object to represent nil options.

  • – representativeHash

    For efficient caching, the output from the reprsesentativeDictionary method is converted into minified canonical JSON, then stored as a sha1 hash.

  • – representativeHashWithOptions:

    Returns a hashed dictionary representation using the given options merged with the options property.

Representation

  • – initWithRepresentativeDictionary:

    Initializes an image renderer with values from a dictionary.

  • – representativeDictionary

    Every image effect can be represented by a dictionary. This can be converted to and from JSON, allowing image properties to be stored in a lightweight text format, read from a server, etc. Likewise, an image renderer can be represented in a dictionary, which would include the representations of its image effects.

Properties

imageEffects

An array of AKImageEffect objects, applied in order.

@property (strong, nonatomic) NSArray *imageEffects

Declared In

AKImageRenderer.h

options

A dictionary of options that will be applied to all images rendered with the renderer.

@property (strong) NSDictionary *options

Declared In

AKImageRenderer.h

Instance Methods

imageWithSize:scale:options:

The main rendering method for an image renderer.

- (UIImage *)imageWithSize:(CGSize)size scale:(CGFloat)scale options:(NSDictionary *)options

Parameters

size

The size (in screen points) to render the final image.

scale

The scale to render the image with. Specify 1 for non-Retina and 2 for Retina screens.

options

A dictionary containing configuration settings for the renderer. Values specified in this dictionary overwrite values in the options property.

Return Value

A fully-rendered UIImage for the given image effects and given size.

Declared In

AKImageRenderer.h

initWithRepresentativeDictionary:

Initializes an image renderer with values from a dictionary.

- (id)initWithRepresentativeDictionary:(NSDictionary *)representativeDictionary

Parameters

representativeDictionary

The dictionary to parse into an image renderer.

Return Value

An image renderer initilaized with values from the dictionary.

Declared In

AKImageRenderer.h

renderedImages

Generates a dictionary representing previously-rendered images, useful for generating pre-rendered images at app startup. The keys are the sizes turned into a string, and the values are sets containing the options dictionaries passed for that size, or an NSNull object to represent nil options.

- (NSDictionary *)renderedImages

Return Value

A dictionary of previously-rendered image information.

Declared In

AKImageRenderer.h

representativeDictionary

Every image effect can be represented by a dictionary. This can be converted to and from JSON, allowing image properties to be stored in a lightweight text format, read from a server, etc. Likewise, an image renderer can be represented in a dictionary, which would include the representations of its image effects.

- (NSDictionary *)representativeDictionary

Return Value

An NSDictionary completely representing the image renderer.

Declared In

AKImageRenderer.h

representativeHash

For efficient caching, the output from the reprsesentativeDictionary method is converted into minified canonical JSON, then stored as a sha1 hash.

- (NSString *)representativeHash

Return Value

The hashed dictionary data as an NSString.

Declared In

AKImageRenderer.h

representativeHashWithOptions:

Returns a hashed dictionary representation using the given options merged with the options property.

- (NSString *)representativeHashWithOptions:(NSDictionary *)options

Parameters

options

Settings applied to the image renderer for which the hash is being computed.

Return Value

The hashed dictionary data as an NSString.

Declared In

AKImageRenderer.h