Well, the entire code is this:
Code: Select all
//Creating base image
$image_width = 1000;
$image_height = 400;
$image = imageCreate($image_width, $image_height);
//Stating line thickness and colors
imagesetthickness($image, 2);
$back_color = imageColorAllocate($image, 56, 141, 192); //BG color of the image
$draw_color = imageColorAllocate($image, 0, 0, 0); //lines and text color
$rect_color = imageColorAllocate($image, 43, 109, 149); //image border color
//Creating rectangular border for the image
imageRectangle($image, 0, 0, imageSX($image) - 1, imageSY($image) - 1, $rect_color);
$font_number = 5;
$text = "Placing chart";
$x_position = ($image_width - (strlen($text) * imagefontwidth($font_number))) / 2;
imagestring($image, $font_number, $x_position, 20, $text, $draw_color);
for($place = 1; $place = 20; $place++)
{
for($y_position=40; $y_position < ((($y_position + imagefontheight($font_number))+5)*20); $y_position += 10)
{
imagestring($image, $font_number, 40, $y_position, $place, $draw_color);
}
}
//Stating image format (options: jpeg, gif, png, wbmp). In this case - PNG.
header('Content-Type: image/png');
imagepng($image);
imageDestroy($image);
I save the file as "php_image.php" and then embed that in my default.php file: [text]<img src = "php_image.php">[/text]
It creates a 1000*400 pixels image. If I remove both loops, it just shows the "Placing chart" text in the middle of the image (which is good). Now I need to create the numbered list on the left side, about 20 pixels on the X axis and 40 on the Y.
Of course I can do it manually, but it's to many lines of code and not an elegant solution. So I'm trying to make it with a loop, but it doesn't work so far...