1. Go to this page and download the library: Download reallifekip/grid-map library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
use ReallifeKip\GridMap\GridMap;
use ReallifeKip\GridMap\Objects\DTOs\Config;
try {
$result = GridMap::slice(
Config::fromArray([
'imageWidth' => 1200,
'imageHeight' => 800,
'columns' => 20,
'rows' => 10,
'cells' => [
['colSpan' => 4, 'rowSpan' => 4], // A
['colSpan' => 8, 'rowSpan' => 4], // B
['colSpan' => 8, 'rowSpan' => 4], // C — must fully fill the grid
['colSpan' => 20, 'rowSpan' => 6], // D
],
])
);
} catch (\Exception $e) {
// Thrown if a slice cannot be placed, or if the grid is left partially unfilled
echo 'Slice failed: ' . $e->getMessage();
}
/** @var ReallifeKip\GridMap\Objects\DTOs\Slice[] $result */
$result[0]->x; // int — left edge in pixels
$result[0]->y; // int — top edge in pixels
$result[0]->width; // int — width in pixels
$result[0]->height; // int — height in pixels
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.