SPImage Class Reference
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
-
– initWithTexture:
Initialize a quad with a texture mapped onto it. Designated Initializer.
-
– initWithContentsOfFile:
Initialize a quad with a texture loaded from a file. No mipmaps will be created.
-
– initWithContentsOfFile:generateMipmaps:
Initialize a quad with a texture loaded from a file.
-
+ imageWithTexture:
Factory method.
-
+ imageWithContentsOfFile:
Factory method.
Methods
-
– setTexCoords:ofVertex:
Sets the texture coordinates of a vertex. Coordinates are in the range [0, 1].
-
– setTexCoordsWithX:y:ofVertex:
Sets the texture coordinates of a vertex. Coordinates are in the range [0, 1].
-
– texCoordsOfVertex:
Gets the texture coordinates of a vertex.
-
– 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.
Properties
-
texture
The texture that is displayed on the quad.
property
Class Methods
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