3raser Posted March 8, 2011 Share Posted March 8, 2011 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. :/ Quote Link to comment https://forums.phpfreaks.com/topic/229926-creating-images-in-php-drawing-rectangles/ Share on other sites More sharing options...
HuggieBear Posted March 8, 2011 Share Posted March 8, 2011 Try changing this: imagefilledrectangle($signature, 0, 1, 150, 30, $red); to this: imagefilledrectangle($signature, 75, 15, 225, 45, $red); Quote Link to comment https://forums.phpfreaks.com/topic/229926-creating-images-in-php-drawing-rectangles/#findComment-1184272 Share on other sites More sharing options...
3raser Posted March 8, 2011 Author Share Posted March 8, 2011 Try changing this: imagefilledrectangle($signature, 0, 1, 150, 30, $red); to this: imagefilledrectangle($signature, 75, 15, 225, 45, $red); It's a little off, but will do! Do you mind if I ask how you can figure this out? Quote Link to comment https://forums.phpfreaks.com/topic/229926-creating-images-in-php-drawing-rectangles/#findComment-1184276 Share on other sites More sharing options...
HuggieBear Posted March 8, 2011 Share Posted March 8, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/229926-creating-images-in-php-drawing-rectangles/#findComment-1184388 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.