Generator::image_gradientrect( GdImage $img, string $start, string $end )
Description #
Fill gradient.
Parameters #
- $imgGdImage (Required) Image resource.
- $startstring (Required) Start color.
- $endstring (Required) End color.
Source #
File: addons/avatar/class-generator.php
private function image_gradientrect( $img, $start, $end ) { $x = 0; $y = 0; $x1 = 90; $y1 = 90; if ( $x > $x1 || $y > $y1 ) { return false; } $start = str_replace( '#', '', $start ); $end = str_replace( '#', '', $end ); $s = array( hexdec( substr( $start, 0, 2 ) ), hexdec( substr( $start, 2, 2 ) ), hexdec( substr( $start, 4, 2 ) ), ); $e = array( hexdec( substr( $end, 0, 2 ) ), hexdec( substr( $end, 2, 2 ) ), hexdec( substr( $end, 4, 2 ) ), ); $steps = $y1 - $y; for ( $i = 0; $i < $steps; $i++ ) { $r = $s[0] - ( ( ( $s[0] - $e[0] ) / $steps ) * $i ); $g = $s[1] - ( ( ( $s[1] - $e[1] ) / $steps ) * $i ); $b = $s[2] - ( ( ( $s[2] - $e[2] ) / $steps ) * $i ); $color = imagecolorallocate( $img, $r, $g, $b ); imagefilledrectangle( $img, $x, $y + $i, $x1, $y + $i + 1, $color ); } return true; }
Expand full source code Collapse full source code View on GitHub: addons/avatar/class-generator.php:293
Add your comment