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.