modules6,990 bytes total
<?
class Color {
var $red;
var $green;
var $blue;
function Color($red, $green, $blue) {
$this->red = $red;
$this->green = $green;
$this->blue = $blue;
}
function add($color) {
return new Color($color->red + $this->red, $color->green + $this->green, $color->blue + $this->blue);
}
function blend($color1, $color2) {
return new Color(($color1->red + $color2->red)/2, ($color1->green + $color2->green)/2, ($color1->blue + $color2->blue)/2);
}
function changeBrightness($percent) {
$this->red *= $percent;
$this->green *= $percent;
$this->blue *= $percent;
if ($this->red > 255) $this->red = 255;
if ($this->green > 255) $this->green = 255;
if ($this->blue > 255) $this->blue = 255;
}
function difference($color) {
$rDiff = $this->red - $color->red;
$gDiff = $this->green - $color->green;
$bDiff = $this->blue - $color->blue;
return new Color($rDiff, $gDiff, $bDiff);
}
function getAlphaColor($level) {
$red = $level + $this->red;
$green = $level + $this->green;
$blue = $level + $this->blue;
if ($red > 255) $red = 255;
if ($green > 255) $green = 255;
if ($blue > 255) $blue = 255;
if ($red < 0) $red = 0;
if ($green < 0) $green = 0;
if ($blue < 0) $blue = 0;
return array($red, $green, $blue);
}
function allocate($image) {
return imagecolorallocate($image, $this->red, $this->green, $this->blue);
}
}
?>