Example of the function of drawing the dice pattern in the Mid-Autumn pie game implemented by php: Mid-Autumn dice
This article describes how to draw a dice in the Mid-Autumn pie game implemented by php. We will share this with you for your reference. The details are as follows:
Recently, the company's Mid-Autumn Festival blog (in Xiamen), I want to play it myself, so I want to write a pure php Mid-Autumn Festival blog game, since it needs to be implemented in pure php, php is used to generate a pattern, so the first step is to draw a dice pattern.
Php is rarely used for plotting, but the information is still drawn. The Code is as follows:
header('Content-Type:image/png');$img = imagecreatetruecolor(200, 200);$white = imagecolorallocate($img, 255, 255, 255);$grey = imagecolorallocate($img, 100, 100, 100);$blue = imagecolorallocate($img, 0, 102, 255);$red = imagecolorallocate($img, 255, 0, 0);imagefill($img, 0, 0, $white);imageline($img, 10, 20, 10, 180, $grey);imageline($img, 10, 180, 20, 190, $grey);imageline($img, 20, 190, 180, 190, $grey);imageline($img, 180, 190, 190, 180, $grey);imageline($img, 190, 180, 190, 20, $grey);imageline($img, 190, 20, 180, 10, $grey);imageline($img, 180, 10, 20, 10, $grey);imageline($img, 20, 10, 10, 20, $grey);//1imagefilledarc($img, 100, 100, 50, 50, 0, 0, $blue, IMG_ARC_PIE);//2//imagefilledarc($img, 60, 100, 40, 40, 0, 0 , $red, IMG_ARC_PIE);//imagefilledarc($img, 140, 100, 40, 40, 0, 0 , $red, IMG_ARC_PIE);//3//imagefilledarc($img, 50, 50, 40, 40, 0, 0 , $blue, IMG_ARC_PIE);//imagefilledarc($img, 100, 100, 40, 40, 0, 0 , $blue, IMG_ARC_PIE);//imagefilledarc($img, 150, 150, 40, 40, 0, 0 , $blue, IMG_ARC_PIE);//4//imagefilledarc($img, 50, 50, 40, 40, 0, 0 , $red, IMG_ARC_PIE);//imagefilledarc($img, 50, 150, 40, 40, 0, 0 , $red, IMG_ARC_PIE);//imagefilledarc($img, 150, 150, 40, 40, 0, 0 , $red, IMG_ARC_PIE);//imagefilledarc($img, 150, 50, 40, 40, 0, 0 , $red, IMG_ARC_PIE);//5//imagefilledarc($img, 50, 50, 40, 40, 0, 0 , $blue, IMG_ARC_PIE);//imagefilledarc($img, 50, 150, 40, 40, 0, 0 , $blue, IMG_ARC_PIE);//imagefilledarc($img, 100, 100, 40, 40, 0, 0 , $blue, IMG_ARC_PIE);//imagefilledarc($img, 150, 150, 40, 40, 0, 0 , $blue, IMG_ARC_PIE);//imagefilledarc($img, 150, 50, 40, 40, 0, 0 , $blue, IMG_ARC_PIE);//6//imagefilledarc($img, 50, 50, 40, 40, 0, 0 , $red, IMG_ARC_PIE);//imagefilledarc($img, 50, 150, 40, 40, 0, 0 , $red, IMG_ARC_PIE);//imagefilledarc($img, 100, 50, 40, 40, 0, 0 , $red, IMG_ARC_PIE);//imagefilledarc($img, 100, 150, 40, 40, 0, 0 , $red, IMG_ARC_PIE);//imagefilledarc($img, 150, 150, 40, 40, 0, 0 , $red, IMG_ARC_PIE);//imagefilledarc($img, 150, 50, 40, 40, 0, 0 , $red, IMG_ARC_PIE);imagepng($img);imagedestroy($img);
You can draw a 1-6 point pattern, 1/3/5 color is blue, 2/4/6 is red, as follows: