<?php
/* SVN FILE: $Id: itemTop.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 imagePngItemTop ($color)
{
    $body = getColors($color);
    $area = getColors('FFFFFF');

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

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

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

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

    imageColorSet($image, 7, $body['r'], $body['g'], $body['b']);

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