<?php
/* SVN FILE: $Id: menubarBg.php 164 2008-04-23 00:36:15Z bb_yujiro $ */
/**
 * 実行処理
 *
 * PHP versions 4 and 5
 *
 *      Hitsuji : Social Network Service <http://rakuto.net/rktSNS/>
 *      Copyright (c) 2007 Yujiro Takahashi
 *
 * Licensed under The MIT License
 * Redistributions of files must retain the above copyright notice.
 *
 * @filesource
 * @package         Hitsuji
 * @copyright       Copyright (c) 2007 Yujiro Takahashi
 * @link            http://rakuto.net/rktSNS/
 * @author          Yujiro Takahashi <yujiro@rakuto.net>
 * @version         $Revision: 164 $
 * @modifiedby      $LastChangedBy: bb_yujiro $
 * @lastmodified    $Date: 2008-04-23 09:36:15 +0900 (豌ｴ, 23 4 2008) $
 * @license         http://opensource.org/licenses/mit-license.php The MIT License
 */

/**
 * 画像の出力
 *
 * @access public
 * @param string $color
 * @return void
 */
function imagePngMenubarBg ($color)
{
    $body  = getColors($color);
    $back  = colorsMultiply($body, RATE_BACK);
    $head  = colorsMultiply($body, RATE_HEAD);
    $verge = colorsMultiply($head, RATE_VERGE);

    $image = imageCreateFromPNG(dirname(__FILE__).'/../source/menubarBg.png');

    $range = 48;
    $rate = array (
        'r'=> abs(($body['r'] - $back['r']) / $range),
        'g'=> abs(($body['g'] - $back['g']) / $range),
        'b'=> abs(($body['b'] - $back['b']) / $range),
    );

    for ($row=0; $row<3; $row++) {
        $index = $row;
        $red   = colorInt($back['r'] - ($row * $rate['r']));
        $green = colorInt($back['g'] - ($row * $rate['g']));
        $blue  = colorInt($back['b'] - ($row * $rate['b']));

        imageColorSet($image, $index, $red, $green, $blue);
    }

    $range = 15;
    $rate = array (
        'r'=> abs(($body['r'] - $verge['r']) / $range),
        'g'=> abs(($body['g'] - $verge['g']) / $range),
        'b'=> abs(($body['b'] - $verge['b']) / $range),
    );

    for ($row=0; $row<28; $row++) {
        $index = $row + 3;
        $red   = colorInt($body['r'] - ($row * $rate['r']));
        $green = colorInt($body['g'] - ($row * $rate['g']));
        $blue  = colorInt($body['b'] - ($row * $rate['b']));

        imageColorSet($image, $index, $red, $green, $blue);
    }

    imagePNG($image);
    imageDestroy($image);
}
?>