php基于GD庫(kù)畫五星紅旗的方法
更新時(shí)間:2015年02月24日 16:02:27 作者:php之路
這篇文章主要介紹了php基于GD庫(kù)畫五星紅旗的方法,涉及php操作GD庫(kù)及數(shù)組的使用技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下
本文實(shí)例講述了php基于GD庫(kù)畫五星紅旗的方法。分享給大家供大家參考。具體分析如下:
這里實(shí)例分析php畫的五星紅旗(GD庫(kù)),代碼如下:
復(fù)制代碼 代碼如下:
<?php
header("Content-Type:image/jpeg");
$ing = imagecreatetruecolor(700,410);
//新建一個(gè)真彩色圖像,返回值為一個(gè)圖像標(biāo)識(shí)符,背景默認(rèn)為黑色,參數(shù)(x_size*y_size)
$red = imagecolorallocate($ing,255,0,0);//定義背景顏色
$yellow = imagecolorallocate($ing,237,231,32);//定義黃色
imagefill($ing,0,0,$red);//填充顏色,以坐標(biāo)(0,0)開始起填充
//數(shù)組坐標(biāo),表示(x1,y1,x2,y2,x3,y3.....x11,y11);
$a = array(90,30,108,73,157,73,119,102,135,152,93,123,52,152,66,102,29,74,76,73,90,30);
imagefilledpolygon($ing,$a,10,$yellow);//畫一個(gè)多邊形:10表示頂點(diǎn)總數(shù),$yellow表示填充色
$a1 = array(229,25,229,43,248,48,229,55,229,74,217,60,198,66,210,50,197,34,218,39,229,25);
imagefilledpolygon($ing,$a1,10,$yellow);
$a2 = array(227,108,227,127,245,134,228,139,227,157,215,143,196,149,208,132,196,117,215,122,227,108);
imagefilledpolygon($ing,$a2,10,$yellow);
$a3 = array(163,184,163,204,181,211,163,216,163,234,152,220,132,225,144,209,132,193,151,199,163,184);
imagefilledpolygon($ing,$a3,10,$yellow);
$a4 = array(65,209,65,228,84,235,65,240,65,259,54,245,33,249,46,233,34,217,53,224,68,209);
imagefilledpolygon($ing,$a4,10,$yellow);
ob_clean();
imagejpeg($ing);
imagedestroy($ing);
?>
header("Content-Type:image/jpeg");
$ing = imagecreatetruecolor(700,410);
//新建一個(gè)真彩色圖像,返回值為一個(gè)圖像標(biāo)識(shí)符,背景默認(rèn)為黑色,參數(shù)(x_size*y_size)
$red = imagecolorallocate($ing,255,0,0);//定義背景顏色
$yellow = imagecolorallocate($ing,237,231,32);//定義黃色
imagefill($ing,0,0,$red);//填充顏色,以坐標(biāo)(0,0)開始起填充
//數(shù)組坐標(biāo),表示(x1,y1,x2,y2,x3,y3.....x11,y11);
$a = array(90,30,108,73,157,73,119,102,135,152,93,123,52,152,66,102,29,74,76,73,90,30);
imagefilledpolygon($ing,$a,10,$yellow);//畫一個(gè)多邊形:10表示頂點(diǎn)總數(shù),$yellow表示填充色
$a1 = array(229,25,229,43,248,48,229,55,229,74,217,60,198,66,210,50,197,34,218,39,229,25);
imagefilledpolygon($ing,$a1,10,$yellow);
$a2 = array(227,108,227,127,245,134,228,139,227,157,215,143,196,149,208,132,196,117,215,122,227,108);
imagefilledpolygon($ing,$a2,10,$yellow);
$a3 = array(163,184,163,204,181,211,163,216,163,234,152,220,132,225,144,209,132,193,151,199,163,184);
imagefilledpolygon($ing,$a3,10,$yellow);
$a4 = array(65,209,65,228,84,235,65,240,65,259,54,245,33,249,46,233,34,217,53,224,68,209);
imagefilledpolygon($ing,$a4,10,$yellow);
ob_clean();
imagejpeg($ing);
imagedestroy($ing);
?>
希望本文所述對(duì)大家的php程序設(shè)計(jì)有所幫助。
相關(guān)文章
php中模擬POST傳遞數(shù)據(jù)的兩種方法分享
php中模擬POST傳遞數(shù)據(jù)的兩種方法分享,有時(shí)候需要模擬提交數(shù)據(jù)方便采集,需要的朋友可以參考下。2011-09-09php中使用preg_replace函數(shù)匹配圖片并加上鏈接的方法
preg_replace 執(zhí)行正則表達(dá)式的搜索和替換,如果只是單純的匹配字符串建議使用str_replace(),因?yàn)槠鋱?zhí)行效率高的多2013-02-02php中3種方法統(tǒng)計(jì)字符串中每種字符的個(gè)數(shù)并排序
3種方法,統(tǒng)計(jì)字符串中每種字符的個(gè)數(shù)并排序,多種解法喲~ str_split()函數(shù)很重要2012-08-08淺談Coreseek、Sphinx-for-chinaese、Sphinx+Scws的區(qū)別
下面小編就為大家?guī)硪黄獪\談Coreseek、Sphinx-for-chinaese、Sphinx+Scws的區(qū)別。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2016-12-12