Jump to content

Creating Images in PHP: Drawing rectangles.


3raser

Recommended Posts

This is so hard. :/

 

I have the following code:

 

<?php
$signature = @imagecreate(350,60);
$image_generate = imagecolorallocate($signature,84, 84, 84);
$red = imagecolorallocate($signature,255,36,0);

imagefilledrectangle($signature, 0, 1, 150, 30, $red);

header("Content-type:image/png");
imagepng($signature);


?>

 

How can I get the rectangle in the center?

 

http://zchighscores.99k.org/image.php

 

I don't really know what to change to get it in the right coordinates. :/

Sorry, my bad, I misread one of your numbers.  Change it to this:

 

imagefilledrectangle($signature, 100, 15, 250, 30, $red);

 

It's really simple, the numbers are just offsets from the top left of the image.

 

In your main image 0,0,350,60 means:

The top left point should be placed 0 pixels from the left of the screen and 0 pixels from the top of the screen.

 

In your main image 0,0,350,60 means:

The bottom right point should be placed 350 pixels from the left of the screen and 60 pixels from the top of the screen.

 

Exactly the same applies for the filled rectangle, but it's numbers are offset against the parent image.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.