2017 © Pedro Peláez
 

library columns3d

Library to create 3D-like columns with GD extension

image

rimelek/columns3d

Library to create 3D-like columns with GD extension

  • Sunday, October 2, 2016
  • by rimelek
  • Repository
  • 1 Watchers
  • 0 Stars
  • 0 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

Description

Using this library you can create images of different type of columns. If you use linear gradient on the column's wall, you can draw 3D-like shapes. It is mainly just for fun and learn algorithms used by the library., (*1)

See some examples: examples.md, (*2)

Installation

php composer.phar require rimelek/columns3d:2.*

Requirements

  • PHP >= 7.0
  • GD extension

Usage

Drawable elements

To start drawing you need to define a canvas, (*3)

use Rimelek\Columns3D\Canvas;
use Rimelek\Columns3D\CanvasConfiguration;
use Rimelek\Columns3D\Color;

$cc = new CanvasConfiguration();
$cc->setHeight(300);
$cc->setWidth(300);
$cc->setType(Canvas::TYPE_JPEG); //Canvas::TYPE_PNG and Canvas::TYPE_GIF are also supported
$cc->setQuality(50); // Only in case of JPEG
$cc->setColor(new Color(255, 0, 0)); //RGB

$canvas = new Canvas($cc);

All methods of CanvasConfiguration are optional., (*4)

You can add elements to the canvas with addElement()., (*5)

use Rimelek\Columns3D\PositionedElement;

// ...

$canvas->addElement(new Positionedelement($drawable, /*x*/ 200, /*y*/ 200));

$drawable object must implement Rimelek\Columns3D\Drawable\DrawableInterface, (*6)

Currently 2 classes are available:, (*7)

StripedPattern, (*8)

This is to add a striped background. For now, it does not support customization., (*9)

use Rimelek\Columns3D\Drawable\StripedPattern;

// ...

$background = new StripedPattern();
$canvas->addElement(new Positionedelement($background, 150, 150)); // background and the center of the canvas

Column, (*10)

use Rimelek\Columns3D\Drawable\Column;
use Rimelek\Columns3D\Drawable\ColumnConfiguration;
use Rimelek\Columns3D\LinearGradient;

// ...

$colc = new ColumnConfiguration();
$colc->setRadius(100);
$colc->setVeticalAngle(0.2); //This is for 3D. Define it between 0 and 1. Greater values mean you look at the column from higher.
$colc->setHeigh(300);
$colc->setWallGradient(new LinearGradient(new Color(0, 0, 0), new Color(255, 255, 255))); 
$colc->setColor(new Color(200 200, 200));

$column = new Column($colc);
$canvas->addElement(new PositionedElement($column, 200, 200));

All methods of ColumnConfiguration are optional., (*11)

Generator classes

There are two generator classes too., (*12)

PositionGenerator, (*13)

It is to generate positions of an ellipse to use it in a foreach loop., (*14)

$positionGenerator = new PositionGenerator($centerX, $centerY, $step /* Default is 1*/);
foreach ($positionGenerator->call(/* start degree*/ -150, /* end degree */ -30) as list($x, $y)) {
    $this->addElement(new PositionedElement($drawable, 200 + $x, 200 + $y));
}

ColumnCircleGenerator, (*15)

Itt uses PositionGenerator to generate circle made of columns., (*16)

$columnCircleGenerator = new ColumnCircleGenerator($positionGenerator, $columnConfiguration);
foreach($columnCircleGenerator->call(/*degree*/$from, /*degree*/$to, $centerX, $centerY) as $e) {
    $canvas->addElement($e);
}

The Versions

02/10 2016

dev-master

9999999-dev

Library to create 3D-like columns with GD extension

  Sources   Download

MIT

The Requires

  • php >=7.0
  • ext-gd *

 

02/10 2016

v2.0.0

2.0.0.0

Library to create 3D-like columns with GD extension

  Sources   Download

MIT

The Requires

  • php >=7.0
  • ext-gd *

 

01/10 2016

v2.0.0-alpha.1

2.0.0.0-alpha1

Library to create 3D-like columns with GD extension

  Sources   Download

MIT

The Requires

  • php >=7.0
  • ext-gd *