c2ephp

SPRFrame Class Reference

Class for a single frame stored in SPR format. More...

Inheritance diagram for SPRFrame:
Collaboration diagram for SPRFrame:

List of all members.

Public Member Functions

 SPRFrame ($reader, $width=0, $height=0, $offset=false)
 Instantiate a new SPRFrame.
 Flip ()
 Flips the image on the y-axis.
 Encode ()
 Encodes the SPRFrame.
 GetGDImage ()
 Gets the GD Image resource for this sprite frame. Deprecated
 GetWidth ()
 Gets the width of the frame in pixels.
 GetHeight ()
 Gets the height of the frame in pixels.
 GetPixel ($x, $y)
 Gets the colour of the pixel at the given position.
 SetPixel ($x, $y, $r, $g, $b)
 Sets the colour of a pixel.
 ToSpriteFrame ($type)
 Converts this SpriteFrame into one of another type.
 ToPNG ()
 Converts this SpriteFrame into a PNG.

Detailed Description

Class for a single frame stored in SPR format.

Definition at line 9 of file SPRFrame.php.


Member Function Documentation

SPRFrame::Encode ( )

Encodes the SPRFrame.

Called automatically by SPRFile::Compile()
Generally end-users won't want a single frame of SPR data, so add it to an SPRFile and call SPRFile::Compile().

Returns:
a binary string of SPR data.

Definition at line 102 of file SPRFrame.php.

SPRFrame::Flip ( )

Flips the image on the y-axis.

This is really for automated use by C1 COBAgentBlocks, but feel free to use it yourself, it's not going anywhere.

Definition at line 60 of file SPRFrame.php.

SpriteFrame::GetGDImage ( ) [inherited]

Gets the GD Image resource for this sprite frame. Deprecated

Returns:
a GD image resource. See http://php.net/image

Definition at line 47 of file SpriteFrame.php.

SpriteFrame::GetHeight ( ) [inherited]

Gets the height of the frame in pixels.

Definition at line 57 of file SpriteFrame.php.

SpriteFrame::GetPixel ( x,
y 
) [inherited]

Gets the colour of the pixel at the given position.

Returns an array like the following:

 Array
 ( 
    [red] => 226
    [green] => 222
    [blue] => 252
    [alpha] => 0 
 )
See also:
http://php.net/imagecolorsforindex
Parameters:
$xThe x-coordinate of the pixel to get.
$yThe y-coordinate of the pixel to get.
Returns:
An associative array containing the keys 'red','green','blue','alpha'.

Definition at line 76 of file SpriteFrame.php.

SpriteFrame::GetWidth ( ) [inherited]

Gets the width of the frame in pixels.

Definition at line 53 of file SpriteFrame.php.

SpriteFrame::SetPixel ( x,
y,
r,
g,
b 
) [inherited]

Sets the colour of a pixel.

Parameters:
$xThe x-coordinate of the pixel to change.
$yThe y-coordinate of the pixel to change.
$rThe red component of the pixel. 0-255.
$gThe green component of the pixel. 0-255.
$bThe blue component of the pixel. 0-255.

Definition at line 91 of file SpriteFrame.php.

SPRFrame::SPRFrame ( reader,
width = 0,
height = 0,
offset = false 
)

Instantiate a new SPRFrame.

If you're creating your own SPRFrame.

See also:
http://php.net/image
Parameters:
$readerEither an IReader or a GD Image resource
$widthIgnored when creating an SPRFrame from a GD image.
$heightIgnored when creating an SPRFrame from a GD image.
$offsetHow far through the IReader the SPRFrame is. May not ever be used.

Definition at line 28 of file SPRFrame.php.

SpriteFrame::ToPNG ( ) [inherited]

Converts this SpriteFrame into a PNG.

Returns:
A binary string in PNG format, ready for output! :)

Definition at line 155 of file SpriteFrame.php.

SpriteFrame::ToSpriteFrame ( type) [inherited]

Converts this SpriteFrame into one of another type.

This is called internally by SpriteFile, and is not really for public use. A way of converting I'd approve of more is to create a SpriteFile of the right type and then call AddFrame.

See also:
SpriteFile::AddFrame()
Parameters:
$typeThe type of SpriteFrame to convert this to.

Definition at line 134 of file SpriteFrame.php.


The documentation for this class was generated from the following file:
 All Classes Files Functions Variables Enumerations