2017 © Pedro Peláez
 

library shapegen

Generates 2D shapes in different sizes

image

dimitrievski/shapegen

Generates 2D shapes in different sizes

  • Friday, November 24, 2017
  • by dimitrievski
  • Repository
  • 1 Watchers
  • 0 Stars
  • 8 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

ShapeGen (Shape Generator)

Generates 2D shapes (circles, ellipses, diamonds, squares, rectangles, triangles) in different sizes., (*1)

Requirements

PHP 7.0 and later., (*2)

Composer

You can install the bindings via Composer. Run the following command:, (*3)

$ composer require dimitrievski/shapegen

To use the bindings, use Composer's autoload:, (*4)

<?php

require __DIR__ . '/vendor/autoload.php';

Getting Started

Simple usage looks like:, (*5)

<?php

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

To generate a shape with different size, pass an additional argument - number of lines. This argument must be an odd number between 5 and 49. The default is 5., (*6)

<?php

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

To generate a shape with different filling, pass one more argument - filling character. This argument must be a string. The default is X., (*7)

<?php

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

To create new shapes, use the shape factory like:, (*8)

<?php

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

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

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

Development

Install dependencies:, (*9)

``` bash $ composer install, (*10)


## Tests Install dependencies as mentioned above (which will resolve [PHPUnit](http://packagist.org/packages/phpunit/phpunit)), then you can run the test suite: ```bash $ ./vendor/bin/phpunit tests/

The Versions

24/11 2017

dev-master

9999999-dev https://github.com/dimitrievski/shapegen

Generates 2D shapes in different sizes

  Sources   Download

MIT

The Requires

  • php ^7.0

 

The Development Requires

by Filip Dimitrievski

generator circle shape diamond 2d rectangle ellipse square triangle

24/11 2017

v1.0.0

1.0.0.0 https://github.com/dimitrievski/shapegen

Generates 2D shapes in different sizes

  Sources   Download

MIT

The Requires

  • php ^7.0

 

The Development Requires

by Filip Dimitrievski

generator circle shape diamond 2d rectangle ellipse square triangle