<?php

/**
 * THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 *
 * @package fusionLib
 * @copyright Copyright (c) 2013 fusionLib. All rights reserved.
 * @link http://fusionlib.com
 */

/**
 * flImageFilterColorize Class
 *
 * Image filter to changes the contrast of the image.
 *
 * @package fusionLib
 */
class flImageFilterColorize {
	/**
	 * Red.
	 *
	 * @var int
	 */
	protected $r;

	/**
	 * Red.
	 *
	 * @var int
	 */
	protected $g;

	/**
	 * Red.
	 *
	 * @var int
	 */
	protected $b;

	/**
	 * Red.
	 *
	 * @var int
	 */
	protected $a;

	/**
	 * Construct the object.
	 *
	 * @param int $r The red level between 0 and 255.
	 * @param int $g The green level between 0 and 255.
	 * @param int $b The blue level between 0 and 255.
	 * @param int $a The alpha level between 0 and 127.
	 */
	function __construct($r, $g, $b, $a = null) {
		$this->r = $r;
		$this->g = $g;
		$this->b = $b;
		$this->a = $a;
	}

	/**
	 * Apply the filter to the image.
	 *
	 * @param flImage $image The image object.
	 */
	function apply($image) {
		imagefilter($image->getImageResource(), IMG_FILTER_COLORIZE, $this->r, $this->g, $this->b, $this->a);
	}
}
