изчертаване на геометрични фигури

Пробвах следния код:
Код:
<?php

// create a blank image
$image = imagecreatetruecolor(400, 300);

// fill the background color
$bg = imagecolorallocate($image, 0, 0, 0);

// choose a color for the ellipse
$col_ellipse = imagecolorallocate($image, 255, 255, 255);

// draw the white ellipse
imagefilledellipse($image, 200, 150, 300, 200, $col_ellipse);

// output the picture
header("Content-type: image/png");
imagepng($image);

?>
изчертава запълнена бяла елипса на черен фон. При всичките ми опити да задам цвят на фона винаги се визуализира черен цвят.
Код:
$bg = imagecolorallocate($image, 255, 255, 255);
трябва да е бял фон, но той пак е черен. На какво се дължи това?
 
Бекграунда го задаваш от първия imagecolorallocate()
<?php

// create a blank image
$image = imagecreatetruecolor(400, 300);

// fill the background color
$bg = imagecolorallocate($image, 255, 255, 255);

// choose a color for the ellipse
$col_ellipse = imagecolorallocate($image,0, 0, 0 );

// draw the white ellipse
imagefilledellipse($image, 200, 150, 300, 200, $col_ellipse);

// output the picture
header("Content-type: image/png");
imagepng($image);

?>
Тоест, така обърнато трябва да ти изчертая черна елипса на бял фон.
 
Може да се използва mimetex както е описано тука:
http://www.forkosh.dreamhost.com/source_mimetexmanual.html
 

Back
Горе