PHP တွင် ImpropenPolygon () သည်အလွန်စိတ်ဝင်စားဖွယ်ကောင်းသောလုပ်ဆောင်မှုတစ်ခုဖြစ်သည်။ ၎င်းသည် Star သို့မဟုတ် Snowflake ပုံစံများကဲ့သို့သောရှုပ်ထွေးသောဂရပ်ဖစ်များကိုဆွဲရန်လိုအပ်သည့်အခါ၎င်းသည်အထူးသဖြင့်အသုံးဝင်သည်။
ဤဆောင်းပါးသည် Imposopenpolygon ကို မည်သို့အသုံးပြုရမည်ကိုဥပမာအားဖြင့်ရှင်းပြပြီးရိုးရှင်းသောငါးပွိုင့်ကြယ်ပွင့်တစ်ပွင့်နှင့်အခြေခံနှင်းပွင့်ဖွဲ့စည်းပုံကိုမည်သို့ဆွဲရမည်ကိုပြသပါမည်။
bool imageopenpolygon(
GdImage $image,
array $points,
int $num_points,
int $color
)
$ Image : ပုံဆွဲခံရဖို့ပုံရိပ်အရင်းအမြစ်။
$ ရမှတ်များ - Vertex artied articine array [x1, y1, x2, y2,] ။
$ numpoints : ဒေါင်လိုက်အရေအတွက်။
$ အရောင် : လိုင်း၏အရောင်။
မှတ်ချက် - Imageopenpolygon () သည် ဤအချက်များကိုစနစ်တကျချိတ်ဆက်သော်လည်းပုံကိုအလိုအလျောက်မပိတ်ပါ။
ပထမ ဦး စွာကျွန်ုပ်တို့သည်ပတ်တူတစ်ခုကို ဖန်တီး. ရိုးရှင်းသောငါးပွင့်ကြယ်ပွင့်တစ်ခုကိုဆွဲယူသည်။
<?php
// ပတ်တူဖန်တီးပါ
$image = imagecreatetruecolor(300, 300);
// အရောင်များကိုသတ်မှတ်ပါ
$backgroundColor = imagecolorallocate($image, 255, 255, 255); // အဖြူရောင်နောက်ခံ
$starColor = imagecolorallocate($image, 255, 0, 0); // အနီရောင်ကြယ်နီ
// နောက်ခံဖြည့်ပါ
imagefill($image, 0, 0, $backgroundColor);
// ငါးပွင့်ကြယ်ပွင့်၏ vertex ကိုသတ်မှတ်ပါ
$points = [
150, 20, // အထိပ်
179, 110,
270, 110,
197, 165,
220, 250,
150, 200,
80, 250,
103, 165,
30, 110,
121, 110
];
// ပွင့်လင်း pentagrams ဆွဲပါ
imageopenpolygon($image, $points, count($points) / 2, $starColor);
// output ကိုပုံ
header('Content-Type: image/png');
imagepng($image);
// ပုံရိပ်အရင်းအမြစ်များကိုဖျက်ဆီး
imagedestroy($image);
?>
Star.php အဖြစ်သိမ်းဆည်းပြီးလျှင်,
https://m66.net/star.php
ရေးဆွဲထားသောငါးပွင့်ကြယ်ပွင့်ကိုသင်တွေ့နိုင်သည်။
ရိုးရှင်းသော snowflake ကို Centrally အချိုးကျဓါတ်ရောင်ခြည်လိုင်းများက simulated လုပ်နိုင်သည်။
<?php
$image = imagecreatetruecolor(300, 300);
$backgroundColor = imagecolorallocate($image, 255, 255, 255);
$snowColor = imagecolorallocate($image, 0, 0, 255);
imagefill($image, 0, 0, $backgroundColor);
// Snowflake စင်တာ
$centerX = 150;
$centerY = 150;
$length = 100;
$arms = 6;
// တစ်ခုချင်းစီကိုအချက်တွက်ချက်ပါ
$points = [];
for ($i = 0; $i < $arms; $i++) {
$angle = deg2rad(360 / $arms * $i);
$x = $centerX + cos($angle) * $length;
$y = $centerY + sin($angle) * $length;
$points[] = $centerX;
$points[] = $centerY;
$points[] = $x;
$points[] = $y;
}
// Snowflakes ဆွဲပါ
imageopenpolygon($image, $points, count($points) / 2, $snowColor);
header('Content-Type: image/png');
imagepng($image);
imagedestroy($image);
?>
Snowflake အဖြစ်သိမ်းဆည်းပြီးလျှင် browser တွင်ဝင်ရောက်ခြင်းကိုရယူပါ။
https://m66.net/snowflake.php
သင်သည် radial အခြေခံ snowflake ဖွဲ့စည်းပုံကိုသင်တွေ့နိုင်သည်။
Imageopenpolygon () သည် open-type ဂရပ်ဖစ်များကိုဆွဲရန်အစွမ်းထက်သောကိရိယာတစ်ခုဖြစ်သည်။ သင်္ချာတွက်ချက်မှုများ (ထိုကဲ့သို့သော trigonometric functions များကဲ့သို့) ကိုပေါင်းစပ်ထားသော, ကြယ်များ, နှင်းများ,
အကယ်. သင်သာအေးသောရှုပ်ထွေးသောဂရပ်ဖစ်များကိုထုတ်လုပ်လိုပါကကွင်းဆက်ယုတ္တိဗေဒကိုပေါင်းစပ်ပြီးဤပုံဆွဲခြင်းစွမ်းရည်ကိုတိုးချဲ့ရန် algorithms ကိုညှိနှိုင်းနိုင်သည်။