Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.

1. imagefilledrectange coordinates

I am trying to figure out imagefilledrectange, I am having a problem understanding x1,y1,x2,y2.

does anybody have a link to tutorial or more in depth explanation.

tia.

• x is the horizontal distance in pixels and y is the vertical distance in pixels.

x1 is the start position (ie the distance between the left hand side of your image and where you want the rectangle to start) and y1 is the distance from the top of your image that you want to start drawing. x2 is the distance from the left side of the image where you want the rectangle to end and y2 is the distance from the top where you want the image to end.

So, if you wanted a rectangle 100 pixels wide by 50 pixels tall starting in the very top left of your image you'd use:

PHP Code:
``` imagefilledrectangle (\$image, 0, 0, 100, 50, \$colour);  ```
Meanwhile if you wanted the same 100x50 pixel rectangle but you wanted it to be placed 10 pixels away from the left hand side and 5 pixels down from the top side of your image, you'd use:

PHP Code:
``` imagefilledrectangle (\$image, 10, 5, 110, 55, \$colour);  ```

• Imagine the image as a x, y graph. The 0,0 point (origin) is the top left corner.
The function draws a rectangle and takes two points as input not one point and width and height. If you'd wan't a function that can do that you could use this:
PHP Code:
``` <?php function draw_rect(\$im, \$x, \$y, \$width, \$hight) {     imagefilledrectangle(\$im, \$x, \$y, \$x + \$width, \$y + \$hight); } ?> ```

•

Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•