Changeset 766 for branches


Ignore:
Timestamp:
03/28/13 12:43:27 (11 years ago)
Author:
ramonb
Message:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/0.4/web/addons/job_monarch/libtoga.php

    r765 r766  
    12891289        $this->size    = $BIG_CLUSTERIMAGE_NODEWIDTH;
    12901290
     1291        $this->drawShadow();
    12911292        $this->draw();
     1293    }
     1294
     1295    function drawShadow()
     1296    {
     1297        // offset of drop shadow from top left
     1298        //
     1299        $ds_offset  = 5;
     1300
     1301        // number of steps from black to background color
     1302        //
     1303        $ds_steps   = 15;
     1304
     1305        // distance between steps
     1306        //
     1307        $ds_spread = 1;
     1308
     1309        // define the background color
     1310        //
     1311        $background = array("r" => 255, "g" => 255, "b" => 255);
     1312
     1313        // create a new canvas.  New canvas dimensions should be larger than the original's
     1314        //
     1315        $width  = $this->size + $ds_offset;
     1316        $height = $this->size + $ds_offset;
     1317
     1318        // determine the offset between colors
     1319        //
     1320        $step_offset = array("r" => ($background['r'] / $ds_steps), "g" => ($background['g'] / $ds_steps), "b" => ($background['b'] / $ds_steps));
     1321
     1322        // calculate and allocate the needed colors
     1323        //
     1324        $current_color = $background;
     1325
     1326        for ($i = 0; $i <= $ds_steps ; $i++)
     1327        {
     1328            $colors[$i] = imagecolorallocate($this->image, round($current_color['r']), round($current_color['g']), round($current_color['b']));
     1329
     1330            $current_color['r'] -= $step_offset['r'];
     1331            $current_color['g'] -= $step_offset['g'];
     1332            $current_color['b'] -= $step_offset['b'];
     1333        }
     1334
     1335        // draw overlapping rectangles to create a drop shadow effect
     1336        //
     1337        for ($i = 3; $i < count($colors); $i++)
     1338        {
     1339            imagefilledrectangle( $this->image, ($this->x + $ds_offset), ($this->y + $ds_offset), ($this->x + $width), ($this->y + $height), $colors[$i] );
     1340            $width -= $ds_spread;
     1341            $height -= $ds_spread;
     1342        }
    12921343    }
    12931344
Note: See TracChangeset for help on using the changeset viewer.