Image_Puzzle
[ class tree: Image_Puzzle ] [ index: Image_Puzzle ] [ all elements ]

Class: Image_Puzzle

Source Location: /Image_Puzzle-0.2.2/Image/Puzzle.php

Class Overview


Image_Puzzle generate puzzle pieces from any image. There is an edges factory to make puzzle in different shapes. An example of using this is as bellow:


Author(s):

Version:

  • @package_version@

Methods


Inherited Variables

Inherited Methods


Class Details

[line 62]
Image_Puzzle generate puzzle pieces from any image. There is an edges factory to make puzzle in different shapes. An example of using this is as bellow:

  1.  require_once 'Image/Puzzle.php';
  2.  $options = array(
  3.    'cols'  => 4,
  4.    'rows'  => 4,
  5.    'edge'  => 'default'
  6.  );
  7.  $puzzle = new Image_Puzzle($options);
  8.  $puzzle->createFromFile('image.jpg');
  9.  $puzzle->saveAll('piece_[row]_[col].gif');



[ Top ]


Method Detail

__construct (Constructor)   [line 137]

Image_Puzzle __construct( [array $options = array()])

Puzzle object constructor. Options parameter is optional.

It allow to set how puzzle will be generated.
Available options are :
transparentColor - Color name or hex string or an RGB array of color wich will be used as transparent. Default is white (string | array)
cols - Number of columns to create. Default is 5 (integer)
rows - Number of rows to create. Default is 5 (integer)
edge - Name of edge wich will be used. For example default, sinus (string)

  • Return: a new puzzle object
  • Access: public

Parameters:

array   $options   —  an associative array of option names and values

[ Top ]

createFromFile   [line 151]

void createFromFile( string $filename)

Create puzzle directly from file.

Currently it is only one avaliable method to create puzzle.

  • Access: public

Parameters:

string   $filename   —  Filename of source image

[ Top ]

getPiece   [line 174]

Image_Puzzle_Piece getPiece( int $row, int $col)

Returns puzzle piece at row $row and col $col.
  • Access: public

Parameters:

int   $row   —  Number of row started from 1
int   $col   —  Number og col started from 1

[ Top ]

saveAll   [line 191]

void saveAll( [string $pattern = 'piece[row]_[col].gif'])

Save all pieces to separate files with given name pattern.

$pattern parameter is used to define filename for each piece.

  • Access: public

Parameters:

string   $pattern   —  Name pattern of files. It can contain [row] and [col] symbols which are replaced to current row and col number

[ Top ]


Documentation generated on Mon, 11 Mar 2019 15:40:20 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.