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

Overview

An SPQuad represents a rectangle with a uniform color or a color gradient.

You can set one color per vertex. The colors will smoothly fade into each other over the area of the quad. To display a simple linear color gradient, assign one color to vertices 0 and 1 and another color to vertices 2 and 3.

The indices of the vertices are arranged like this:

0 - 1
| / |
2 - 3

Colors

Colors in Sparrow are defined as unsigned integers, that’s exactly 8 bit per color. The easiest way to define a color is by writing it as a hexadecimal number. A color has the following structure:

0xRRGGBB

That means that you can create the base colors like this:

0xFF0000 -> red
0x00FF00 -> green
0x0000FF -> blue

Other simple colors:

0x000000 or 0x0 -> black
0xFFFFFF        -> white
0x808080        -> 50% gray

If you’re not comfortable with that, there is also a utility macro available that takes the values for R, G and B separately:

uint red = SP_COLOR(255, 0, 0)

Tasks

Initialization

Methods

Properties

  •   color

    Sets the colors of all vertices simultaneously. Returns the color of vertex ‘0’.

    property

Properties

color

Sets the colors of all vertices simultaneously. Returns the color of vertex ‘0’.

@property (nonatomic, assign) uint color

Discussion

Sets the colors of all vertices simultaneously. Returns the color of vertex ‘0’.

Declared In

SPQuad.h

Class Methods

quad

Factory method. Creates a 32x32 quad.

+ (SPQuad *)quad

Discussion

Factory method. Creates a 32x32 quad.

Declared In

SPQuad.h

quadWithWidth:height:

Factory method.

+ (SPQuad *)quadWithWidth:(float)width height:(float)height

Discussion

Factory method.

Declared In

SPQuad.h

quadWithWidth:height:color:

Factory method.

+ (SPQuad *)quadWithWidth:(float)width height:(float)height color:(uint)color

Discussion

Factory method.

Declared In

SPQuad.h

Instance Methods

colorOfVertex:

Returns the color of a vertex.

- (uint)colorOfVertex:(int)vertexID

Discussion

Returns the color of a vertex.

Declared In

SPQuad.h

initWithWidth:height:

Initializes a white quad with a certain size.

- (id)initWithWidth:(float)width height:(float)height

Discussion

Initializes a white quad with a certain size.

Declared In

SPQuad.h

initWithWidth:height:color:

Initializes a quad with a certain size and color. Designated Initializer.

- (id)initWithWidth:(float)width height:(float)height color:(uint)color

Discussion

Initializes a quad with a certain size and color. Designated Initializer.

Declared In

SPQuad.h

setColor:ofVertex:

Sets the color of a vertex.

- (void)setColor:(uint)color ofVertex:(int)vertexID

Discussion

Sets the color of a vertex.

Declared In

SPQuad.h