Inherits from SPQuad : SPDisplayObject : SPEventDispatcher : NSObject
Declared in SPImage.h

Overview

An SPImage displays a quad with a texture mapped onto it.

Sparrow uses the SPTexture class to represent textures. To display a texture, you have to map it on a quad - and that’s what SPImage is for.

As SPImage inherits from SPQuad, you can give it a color. For each pixel, the resulting color will be the result of the multiplication of the color of the texture with the color of the quad. That way, you can easily tint textures with a certain color.

Furthermore, SPImage allows the manipulation of texture coordinates. That way, you can move a texture inside an image without changing any vertex coordinates of the quad. You can also use this feature as a very efficient way to create a rectangular mask.

Tasks

Initialization

Methods

Properties

  •   texture

    The texture that is displayed on the quad.

    property

Properties

texture

The texture that is displayed on the quad.

@property (nonatomic, strong) SPTexture *texture

Discussion

The texture that is displayed on the quad.

Declared In

SPImage.h

Class Methods

imageWithContentsOfFile:

Factory method.

+ (instancetype)imageWithContentsOfFile:(NSString *)path

Discussion

Factory method.

Declared In

SPImage.h

imageWithTexture:

Factory method.

+ (instancetype)imageWithTexture:(SPTexture *)texture

Discussion

Factory method.

Declared In

SPImage.h

Instance Methods

initWithContentsOfFile:

Initialize a quad with a texture loaded from a file. No mipmaps will be created.

- (instancetype)initWithContentsOfFile:(NSString *)path

Discussion

Initialize a quad with a texture loaded from a file. No mipmaps will be created.

Declared In

SPImage.h

initWithContentsOfFile:generateMipmaps:

Initialize a quad with a texture loaded from a file.

- (instancetype)initWithContentsOfFile:(NSString *)path generateMipmaps:(BOOL)mipmaps

Discussion

Initialize a quad with a texture loaded from a file.

Declared In

SPImage.h

initWithTexture:

Initialize a quad with a texture mapped onto it. Designated Initializer.

- (instancetype)initWithTexture:(SPTexture *)texture

Discussion

Initialize a quad with a texture mapped onto it. Designated Initializer.

Declared In

SPImage.h

readjustSize

Readjusts the dimensions of the image according to its current texture. Call this method to synchronize image and texture size after assigning a texture with a different size.

- (void)readjustSize

Discussion

Readjusts the dimensions of the image according to its current texture. Call this method to synchronize image and texture size after assigning a texture with a different size.

Declared In

SPImage.h

setTexCoords:ofVertex:

Sets the texture coordinates of a vertex. Coordinates are in the range [0, 1].

- (void)setTexCoords:(SPPoint *)coords ofVertex:(int)vertexID

Discussion

Sets the texture coordinates of a vertex. Coordinates are in the range [0, 1].

Declared In

SPImage.h

setTexCoordsWithX:y:ofVertex:

Sets the texture coordinates of a vertex. Coordinates are in the range [0, 1].

- (void)setTexCoordsWithX:(float)x y:(float)y ofVertex:(int)vertexID

Discussion

Sets the texture coordinates of a vertex. Coordinates are in the range [0, 1].

Declared In

SPImage.h

texCoordsOfVertex:

Gets the texture coordinates of a vertex.

- (SPPoint *)texCoordsOfVertex:(int)vertexID

Discussion

Gets the texture coordinates of a vertex.

Declared In

SPImage.h