|
02-08-2009, 12:23
|
|
|
|
חבר מתאריך: 09.04.02
הודעות: 8,000
|
|
הנה דוגמה, למרות שאני לא ממש מצליח לחשוב על סיבה לעשות את זה:
http://dor.webfactional.com/pngajax
הקוד של image.php:
קוד PHP:
<?php
function imagegradient($image, $color_start, $color_end, $color_step, $x1, $y1, $x2, $y2)
{
$gradient_height = abs($y2 - $y1);
$color_start = array(
'r' => base_convert(substr($color_start, 0, 2), 16, 10),
'g' => base_convert(substr($color_start, 2, 2), 16, 10),
'b' => base_convert(substr($color_start, 4, 2), 16, 10)
);
$color_end = array(
'r' => base_convert(substr($color_end, 0, 2), 16, 10),
'g' => base_convert(substr($color_end, 2, 2), 16, 10),
'b' => base_convert(substr($color_end, 4, 2), 16, 10)
);
$color_factor = array(
'r' => ($color_end['r'] - $color_start['r']) / $gradient_height,
'g' => ($color_end['g'] - $color_start['g']) / $gradient_height,
'b' => ($color_end['b'] - $color_start['b']) / $gradient_height
);
for ($y = 0; $y < $gradient_height; $y += $color_step + 1)
{
$r = $y * $color_factor['r'] + $color_start['r'];
$g = $y * $color_factor['g'] + $color_start['g'];
$b = $y * $color_factor['b'] + $color_start['b'];
$color_allocated = imagecolorallocate($image, $r, $g, $b);
imagefilledrectangle($image, 0, $y, abs($x2 - $x1), $y + $color_step, $color_allocated);
}
}
$image = imagecreate(100, 40);
imagecolorallocate($image, 255, 0, 0);
imagegradient($image, $_GET['c1'], $_GET['c2'], 1, 0, 0, 100, 40);
ob_start();
imagepng($image);
$image_data = ob_get_clean();
header('Content-type: text/plain');
echo base64_encode($image_data);
נערך לאחרונה ע"י דור בתאריך 02-08-2009 בשעה 12:44.
|
|