Reference/Graphics

Graphics Library

The Graphics class

The Graphics class is the main class for working with graphics of all sorts.

Creating a new image

$i = Graphics::create(400,300);
$i = $this->graphics->create(400,300);

Loading an existing image

$i = Graphics::load('file.png');
$i = $this->graphics->load('file.png');

The ImageCanvas class

Working with Colors

Working with Fonts

Drawing operations

Image operations

Resizing images

Resizing images is done using the resize() method. It accepts three arguments, the width, the height, and a flag to control the resize process:

function resize($width, $height, [$mode=ImageCanvas::KEEP_NONE [, $fillcolor=null]])

The mode can be one of:

  • ImageCanvas::KEEP_NONE - resizes the image to fit the new dimensions ignoring the aspect ratios. The image will be stretched to fill the new size.
  • ImageCanvas::KEEP_CROP - resizes the image to fill the new image on both dimensions while maintaining the aspect ratio before it crops the image to the desired size.
  • ImageCanvas::KEEP_PAD - resizes the image to fit inside the dimensions of the new image and then fills it with the color specified in parameter 4.

The fillcolor is a normal Color() value.

Cropping images

work in progress -- assigned miniman

Lines and curves

work in progress -- assigned noccy

Saving and displaying