主頁 > 知識庫 > php實(shí)現(xiàn)的中秋博餅游戲之繪制骰子圖案功能示例

php實(shí)現(xiàn)的中秋博餅游戲之繪制骰子圖案功能示例

熱門標(biāo)簽:服務(wù)器配置 團(tuán)購網(wǎng)站 科大訊飛語音識別系統(tǒng) 電子圍欄 Linux服務(wù)器 銀行業(yè)務(wù) 阿里云 Mysql連接數(shù)設(shè)置

本文實(shí)例講述了php實(shí)現(xiàn)的中秋博餅游戲之繪制骰子圖案功能。分享給大家供大家參考,具體如下:

最近公司中秋博餅(在廈門),自己沒事也想玩玩,所以就想動手寫了一個純php實(shí)現(xiàn)的中秋博餅游戲,既然要純php實(shí)現(xiàn),就要用php來生成圖案,所以第一步就先繪制骰子圖案。

平時很少使用php繪圖,不過查查資料還是繪制出來了,不多說了,代碼如下:

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);
//1
imagefilledarc($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);

可以繪制出1-6點(diǎn)各點(diǎn)圖案,1/3/5顏色是藍(lán)色,2/4/6是紅色,效果圖如下:

更多關(guān)于PHP相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《PHP圖形與圖片操作技巧匯總》、《PHP基本語法入門教程》、《php面向?qū)ο蟪绦蛟O(shè)計(jì)入門教程》、《PHP網(wǎng)絡(luò)編程技巧總結(jié)》、《PHP數(shù)組(Array)操作技巧大全》、《php字符串(string)用法總結(jié)》、《php+mysql數(shù)據(jù)庫操作入門教程》及《php常見數(shù)據(jù)庫操作技巧匯總》

希望本文所述對大家PHP程序設(shè)計(jì)有所幫助。

您可能感興趣的文章:
  • php實(shí)現(xiàn)的網(wǎng)頁版剪刀石頭布游戲示例
  • php實(shí)現(xiàn)貪吃蛇小游戲
  • php猜單詞游戲
  • php實(shí)現(xiàn)的簡易掃雷游戲?qū)嵗?/li>
  • PHP實(shí)現(xiàn)扎金花游戲之大小比賽的方法
  • jQuery+PHP實(shí)現(xiàn)的擲色子抽獎游戲?qū)嵗?/li>
  • PHP使用header()輸出圖片緩存實(shí)例
  • php將圖片文件轉(zhuǎn)換成二進(jìn)制輸出的方法
  • php讀取圖片內(nèi)容并輸出到瀏覽器的實(shí)現(xiàn)代碼
  • PHP提取數(shù)據(jù)庫內(nèi)容中的圖片地址并循環(huán)輸出
  • php實(shí)現(xiàn)的中秋博餅游戲之?dāng)S骰子并輸出結(jié)果功能詳解

標(biāo)簽:萍鄉(xiāng) 江蘇 廣元 棗莊 衡水 衢州 蚌埠 大理

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《php實(shí)現(xiàn)的中秋博餅游戲之繪制骰子圖案功能示例》,本文關(guān)鍵詞  ;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 收縮
    • 微信客服
    • 微信二維碼
    • 電話咨詢

    • 400-1100-266