PHP Classes
elePHPant
Icontem

File: docs/classes/figure.md

Recommend this page to a friend!
  Classes of Jose Luis Quintana  >  GImage  >  docs/classes/figure.md  >  Download  
File: docs/classes/figure.md
Role: Example script
Content type: text/markdown
Description: Example script
Class: GImage
Create graphic images with a fluent interface
Author: By
Last change: fix docs typo
Date: 28 days ago
Size: 729 bytes
 

Contents

Class file image Download

Figure

> Figure class allows to create rectangles or ellipses shapes.

The following example creates a rectangle, set opacity to 75% and save it as PNG:

<?php

use GImage\Figure;

$rectangle = new Figure(400, 250);
$rectangle
    // Figures are rectangles by default
    // ->isRectangle()
    ->setBackgroundColor(0, 0, 255)
    ->setOpacity(0.75)
    ->create()
    ->save('/home/my_user/images/reactangle.png');

As above example, we can also create an ellipse:

<?php

use GImage\Figure;

$ellipse = new Figure(300, 300);
$ellipse
    // Figure as an Elipse
    ->isEllipse()
    ->setBackgroundColor(255, 0, 0)
    ->setOpacity(0.5)
    ->create()
    ->save('/home/my_user/images/ellipse.png');