PHP တွင် Impleopenpolygon () function ကို အသုံးပြု. ဓာတ်ပုံတစ်ပုံတွင် polygon ဆွဲရန်အသုံးပြုသည်။ ဤလုပ်ဆောင်ချက်၏ syntax သည်အောက်ပါအတိုင်းဖြစ်သည် -
bool imageopenpolygon(resource $image, array $points, int $num_points, int $color)
$ Image : များသောအားဖြင့် isagecreate () သို့မဟုတ် imagecreatjpeg ကဲ့သို့သောလုပ်ဆောင်မှုများဖြင့်ဖန်တီးထားသော function image image image အရင်းအမြစ်။
$ ရမှတ်များ - အနားတစ်ခုစီ၏သွဒီနိတ်များပါ 0 င်သည့်ခင်းကျင်းမှု။ သွဒီနိတ်တစ်ခုစီတွင်ကိန်းဂဏန်းနှစ်ခု (x နှင့် y) ပါဝင်သည်။
$ numpoints : polygon ၏ဒေါဓိပ်မှုအရေအတွက်။
$ အရောင် - များသောအားဖြင့် imagecolorallallate () သို့မဟုတ် imagecolorallocealpha () functions များကိုဖန်တီးသောအနားများဆွဲရန်အသုံးပြုသောအရောင်။
Imageopenpolygon () function တွင် $ အရောင် parameter သည် polygon ၏အရောင်အရောင်ကိုဆုံးဖြတ်သည်။ အကယ်. သင်သည်အရောင်ကိုသတ်မှတ်လိုပါကအရောင်တန်ဖိုးကိုသတ်မှတ်ရန် စိတ်ကူးယဉ်ပုံသဏ္ဌာန် () function ကိုအသုံးပြုရန်လိုအပ်သည်။ ဤလုပ်ဆောင်ချက်ပုံစံသည်
int imagecolorallocate(resource $image, int $red, int $green, int $blue)
$ Image သည်ပုံရိပ်အရင်းအမြစ်သည်ပစ်မှတ်ထားသည့်ပုံရိပ်သည် 0 မှ 255 အထိရှိသည့် အနီ , $ အစိမ်းရောင် ,
<?php
// a 400x400 ရုပ်ပုံများ
$image = imagecreate(400, 400);
// အရောင်များကိုသတ်မှတ်ပါ
$bg_color = imagecolorallocate($image, 255, 255, 255); // အဖြူရောင်နောက်ခံ
$polygon_color = imagecolorallocate($image, 0, 0, 255); // အပြာရောင်အနား
// အနား၏ vertices ကိုသတ်မှတ်ပါ
$points = array(
100, 100, // အစွန်း 1 (x1, y1)
300, 100, // အစွန်း 2 (x2, y2)
350, 250, // အစွန်း 3 (x3, y3)
250, 350, // အစွန်း 4 (x4, y4)
150, 250 // အစွန်း 5 (x5, y5)
);
// ပုံများပေါ်တွင်အနားများဆွဲပါ
imageopenpolygon($image, $points, count($points) / 2, $polygon_color);
// output ကိုပုံ
header('Content-Type: image/png');
imagepng($image);
// ပုံရိပ်အရင်းအမြစ်များကိုဖျက်ဆီး
imagedestroy($image);
?>
image အရင်းအမြစ်ကိုဖန်တီးပါ ။
အရောင်များကိုသတ်မှတ်ပါ - နောက်ခံနှင့်အနားသို့အရောင်များကိုအရောင်များကိုသတ်မှတ်ရန် isaugeColoranation () ကိုသုံးပါ။ နောက်ခံမှာအဖြူရောင် (RGB: 255, 255, 255), Polygon သည်အပြာရောင်ဖြစ်သည် (RGB: 0, 0, 0, 255) ။
Collygon ကိုဆွဲခြင်း - Imageopenpolygon () function မှတဆင့် Polygon သည် set vertex array $ polygon_color ကို အသုံးပြု. polygon_ ကို အသုံးပြုသည်။
Imageopenpolygon () function သည် image အရင်းအမြစ်များကိုအလိုအလျောက်မပိတ်ပါ,
ပွင့်လင်းမြင်သာမှုအကျိုးသက်ရောက်မှုကိုအသုံးပြုရန်, သင်သည် transparency နှင့်အရောင်များကိုဖန်တီးရန် imagecolorallocatealpha () ကို သုံးနိုင်သည်။
အထက်ဖော်ပြပါနည်းလမ်းဖြင့် Polygons များကိုပုံပေါ်ရှိအရောင်များဖြင့်အလွယ်တကူဆွဲနိုင်သည်။