Some doubts about PHP drawing

Source: Internet
Author: User
Some questions about PHP drawing


PHP Code
  
   $SRC 621 = imagecreate (200,200); $yellow = Imagecolorallocate ($src 621, 255, 255, 0); $red = Imagecolorallocate ($src 621, 255, 0, 0); $green = Imagecoloralloca Te ($src 621, 0, 255, 0), Imagerectangle ($src 621, $green), Imagefill ($src 621, 0, 0, $red); Header ("content- Type:image/png "); Imagepng ($src 621); Imagedestroy ($SRC 621);


Results:


Question one, yellow color is how to be painted up?
Question two, Imagefill function of the middle 2 parameters what is the use? (self-test found that the change does not work, if the change is big, there is no fill color)

Ask the cattle man to answer. Thank you!!

------Solution--------------------
Note: The first call to Imagecolorallocate () fills the background color.
Imagefill ($SRC 621, 0, 0, $red);//Comment out the sentence and you'll see it.
ImageFile is the point area fill, the upper left corner is (0,0)
Yellow, meaning to fill all red (selection) into $red, like a paint cartridge in PS
This constituency is the key, why the red inside is not filled, it is because
Imagerectangle ($SRC 621, Max, $green);//Rectangle border is green
This green is separated from the red, that is, the inside to the outside red not a constituency
I don't believe you can change this test again.
Imagefill ($SRC 621, 101, Wuyi, $red);//So run the rectangle inside, select the red area inside the rectangle


------Solution--------------------
For a resource created by Imagecreate, the first color created is the background color
The middle 2 parameters of the Imagefill function are the start coordinates (origin) of the fill, starting at this point until the boundary, all reachable positions and the same color as the origin are set to the specified color

For you to change a hollow rectangle before Imagefill (imagerectangle) so the edge of the rectangle is the boundary
Without being filled, it's natural to reveal the background.
  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.