Image_Puzzle documentation
Table of contents
-
Introduction
-
Installation
Image_Puzzle is a part of PEAR so if you already have PEAR installed just run
pear install Image_PuzzleBecause Image_Puzzle requires Image_Color2 package you need to install it before in the same way.If you don't have PEAR you can install PEAR before or install Image_Puzzle manually. In order to do that you need to download Image_Puzzle package and Image_Color2 package and untar both to directory called Image which sits in your include_path. As a result you should see a directory structure like:
Image Color2 Model Puzzle Edge -
Quick start
The following example demonstrates how to create puzzle pieces with default options. It creates 25 pieces (5 rows and 5 colums) and saves them to the current directory with default pattern of names: piece_1_1.gif, piece_1_2.gif up to piece_5_5.gif.
<?php
require_once 'Image/Puzzle.php';
$puzzle = new Image_Puzzle();
$puzzle->createFromFile('image.jpg');
$puzzle->saveAll();
?>In order to change number of columns or rows it is possible to set options array and pass it into class constructor. For example:
<?php
require_once 'Image/Puzzle.php';
$options = array(
'rows' => 8,
'cols' => 7
);
$puzzle = new Image_Puzzle($options);
$puzzle->createFromFile('image.jpg');
$puzzle->saveAll();
?> -
Options
There are following options you can change before generate new puzzle:
Option Description Default transparentColor Colour which will be used as transparent in generated piece images. white cols 5 rows 5 edge default -
API Documentation
-
PHPDoc Documentation
PEAR Repository automatically generates documentation from PHPDoc for each its package. Please visit documentation for latest version of Image_Puzzle.