PHP code example of dimitrievski / shapegen

1. Go to this page and download the library: Download dimitrievski/shapegen 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/ */

    

dimitrievski / shapegen example snippets







$shapeGen = new \ShapeGen\ShapeGen();
echo $shapeGen->generate("diamond");
//    X
//  XXXXX
//XXXXXXXXX
//  XXXXX
//    X



$shapeGen = new \ShapeGen\ShapeGen();
echo $shapeGen->generate("diamond", 9);
//        X
//      XXXXX
//    XXXXXXXXX
//  XXXXXXXXXXXXX
//XXXXXXXXXXXXXXXXX
//  XXXXXXXXXXXXX
//    XXXXXXXXX
//      XXXXX
//        X



$shapeGen = new \ShapeGen\ShapeGen();
echo $shapeGen->generate("diamond", 9, "D");
//        D
//      DDDDD
//    DDDDDDDDD
//  DDDDDDDDDDDDD
//DDDDDDDDDDDDDDDDD
//  DDDDDDDDDDDDD
//    DDDDDDDDD
//      DDDDD
//        D



$shapeFactory = new \ShapeGen\ShapeFactory();
$diamond = $shapeFactory->create("diamond");

//set different size and filling
$diamond->setLines(15);
$diamond->setFilling("-");

echo $diamond->generate();
//              -
//            -----
//          ---------
//        -------------
//      -----------------
//    ---------------------
//  -------------------------
//-----------------------------
//  -------------------------
//    ---------------------
//      -----------------
//        -------------
//          ---------
//            -----
//              -