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/ */
reallifekip / grid-map example snippets
use ReallifeKip\GridMap\GridMap;
// Canvas size: 1920x1080; divided into 24 x 12 grid (typical 16:9 split)
$gm = new GridMap(
area_w: 1920,
area_h: 1080,
grids_w: 24,
grids_h: 12,
);
// Define slices: each element is [grid_width, grid_height]
// Example: [6,6] means 6x6 grid cells
$slices = [
[6, 6],
[6, 6],
[6, 6],
[6, 6],
[12, 6], // width 12, height 6
[12, 6],
];
$areas = $gm->slice($slices);
print_r($areas);
use ReallifeKip\GridMap\GridMap;
$gm = new GridMap(1200, 800, 20, 10);
$slices = [
[4, 4], // A
[8, 4], // B
[4, 2], // C
[6, 6], // D may not fit later
];
try {
$areas = $gm->slice($slices);
} catch (\Exception $e) {
// Thrown if a slice cannot be placed
echo 'Slice placement failed: ' . $e->getMessage();
}