gradient-in-gd-snipper

Gesponsorde koppelingen

PHP script bestanden

  1. gradient-in-gd-snipper

« Lees de omschrijving en reacties

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
$image
= imagecreate(200,200);
$achtergrond = imagecolorallocate($image,0,0,255);
function
decodeRgbColor($color) {
            if (preg_match('/^\#[0-9a-f]+$/', $color)) {
                $color = substr($color, 1);
                switch (strlen($color)) {
                    case
6:
                        return array(hexdec(substr($color, 0, 2)),
                                     hexdec(substr($color, 2, 2)),
                                     hexdec(substr($color, 4)));
                    case
3:
                        return array(hexdec($color[0] . $color[0]),
                                     hexdec($color[1] . $color[1]),
                hexdec($color[2] . $color[2]));
                case
1:
                return array(hexdec($color[0] . $color[0]),
                hexdec($color[0] . $color[0]),
                hexdec($color[0] . $color[0]));
            default:

            return array(0, 0, 0);
        }
    }

    else
    {
        return array(0, 0, 0);
    }
}


gradient($image,0,0,200,200,decodeRgbColor("#ffffff"),decodeRgbColor("#000000"));



function
gradient($image, $x1, $y1, $x2, $y2, $color_start, $color_end,$reverse=0)
{

    if($reverse != 0)
    {

        $color1 = $color_start;
        $color2 = $color_end;
        $color_start = $color2;
        $color_end = $color1;
    }

    $steps = ($y2 - $y1);
    $inc_r = ($color_end[0] - $color_start[0]) / $steps;
    $inc_g = ($color_end[1] - $color_start[1]) / $steps;
    $inc_b = ($color_end[2] - $color_start[2]) / $steps;
            
    $c = $color_start;
    while ($y2 > $y1)
    {

        $c[0] += $inc_r;
        $c[1] += $inc_g;
        $c[2] += $inc_b;
        $cl = imagecolorallocate($image, $c[0], $c[1], $c[2]);
        imageline($image, $x1, $y1, $x2, $y1++, $cl);
    }
}

imagepng($image);
imagedestroy($image);
?>

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.