<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                一起來看看下面有一張圖: ![document/2015-09-19/55fd0208765ad](http://box.kancloud.cn/document_2015-09-19_55fd0208765ad.png) 我們該怎么把這張圖給畫出來呢。 我們按照步驟能夠分析出來: 1. 畫圖 2. 準備好畫這張圖需要的顏色 3. 填充背景顏色 4. 畫兩條對角線 5. 在上面畫一個圓 6. 在圓上面畫一個矩型 7. 保存圖片 8. 銷毀資源 **一、我們根據這張圖推出出來步驟。我們來分析需要使用到的函數:** ~~~ //使用imagecreate函數創建圖片,返回資源 $img = imagecreate(500,500); ~~~ **二、圖片創建完成我們需要向圖片資源填加顏色,需要使用到函數** ~~~ $顏色變量 = imagecolorallocate ( resource $圖片資源 , int $紅 , int $綠 , int $藍 ) ~~~ 紅、綠、藍是計算機里面操作圖片的三個基本色。由這三個顏色來組合成我們肉眼所看到的所有顏色。 因此 imagecolorallocate 先輸入圖片資源,操作這個資源。為這個圖片資源準備顏色。 就相當于在畫畫的時候,先把畫布準備好,再準備顏料。 根據這張圖,我們需要準備出來的顏色有: 1. 綠 2. 藍 3. 黑 4. 棕 按照計算機的配色原則分配的話,我們下面的顏色分配的代碼就要寫成下面的樣子: ~~~ //紅 $red = imagecolorallocate($img, 255, 0, 0); //綠 $green = imagecolorallocate($img, 0, 255, 0); //藍 $blue = imagecolorallocate($img, 0, 0, 255); //棕 $yellow = imagecolorallocate($img, 121, 72, 0); ~~~ 這中圖片中需要用到的幾個顏色的色值。 **三、 將顏色添加到背景進行填充** ~~~ imagefilledrectangle ( resource $圖片資源 , int $點1x軸, int $點1y軸 , int $點2x軸 , int $點2y軸 , int $color ) ~~~ 這個函數需要涉及到幾何的一點點知識。 1. 一個點由x 坐標和y 坐標組成一個點 2. 兩個點可以組成一個直線 3. 這條線如果不是水平或者垂直的線可以組成一個矩形 如下圖: ![document/2015-09-19/55fd0d5be46bb](http://box.kancloud.cn/document_2015-09-19_55fd0d5be46bb.png) 點1和點2,可以變成一個矩形。因此,我們輸出兩個坐標點,可以對畫布進行填充。 如果要填充整個畫布的話: 點1 為x軸為畫布的0位置,點1的y軸也為畫布的0位置。 點2 為x軸為畫布的500位置,點2的y軸也為畫布的500位置。 **四、畫兩條對角線** 畫一條對角線,對角線是紅色。 第一條對角線的坐標為0和0,500和500 第二條對角線的坐標為500和0,0和500 ~~~ imageline($img, 0, 0, 500, 500, $red); imageline($img, 500, 0, 0, 500, $blue); ~~~ **五、在上面畫一個圓** > bool imagefilledellipse ( resource $圖片資源 , int $圓心x , int $圓心y , int $圓的寬 , int $圓的高 , int $圓的顏色 ) ~~~ imagefilledellipse($img, 250, 250, 200, 200, $yellow); ~~~ 操作這個資源,寫上圓心的坐標。然后寫上長和寬。如果長寬一致為正圓,不一致則為橢圓。 **六、在圓上面畫一個矩型** ~~~ imagefilledrectangle($img, 200, 200, 300, 300, $blue); ~~~ 這個我們在上面一個中講過,我們就不細說了。 **七、保存圖片** > bool imagejpeg ( resource $image [, string $filename]) **八、銷毀圖片資源** imagedestroy($img); 我們來看一下最終組合出來的代碼: ~~~ <?php //創建圖片 $img = imagecreatetruecolor(500, 500); //分配顏色 $red = imagecolorallocate($img, 255, 0, 0); $green = imagecolorallocate($img, 0, 255, 0); $blue = imagecolorallocate($img, 0, 0, 255); $pur = imagecolorallocate($img, 255, 0, 255); $yellow = imagecolorallocate($img, 121, 72, 0); //填充背景 imagefilledrectangle($img, 0, 0, 500, 500, $green); //畫對角線 imageline($img, 0, 0, 500, 500, $red); imageline($img, 500, 0, 0, 500, $blue); //畫圓 imagefilledellipse($img, 250, 250, 200, 200, $yellow); //圓中間畫矩形 imagefilledrectangle($img, 200, 200, 300, 300, $blue); //保存圖片,圖片名為haha.jpg imagejpeg($img, 'haha.jpg'); //銷毀資源 imagedestroy($img); ?> ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看