Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Apr 2005
    Posts
    388
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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.

  • #2
    Regular Coder
    Join Date
    Feb 2005
    Location
    West Midlands, UK
    Posts
    623
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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 ($image0010050$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 ($image10511055$colour); 

  • #3
    Senior Coder
    Join Date
    Aug 2003
    Location
    One step ahead of you.
    Posts
    2,815
    Thanks
    0
    Thanked 3 Times in 3 Posts
    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);
    }
    ?>
    I'm not sure if this was any help, but I hope it didn't make you stupider.

    Experience is something you get just after you really need it.
    PHP Installation Guide Feedback welcome.


  •  

    Posting Permissions

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