চিত্রপূর্ণ বহুভুজ() একটি অন্তর্নির্মিত PHP ফাংশন যা একটি ভরা বহুভুজ আঁকতে ব্যবহৃত হয়।
সিনট্যাক্স
bool imagefilledpolygon($image, $points, $num_points, $color)
পরামিতি
চিত্রপূর্ণ বহুভুজ() চারটি ভিন্ন প্যারামিটার লাগে - $image, $points, $num_points, এবং $color।
-
$ছবি − imagecreatetruecolor() ফাংশন ব্যবহার করে একটি প্রদত্ত আকারে একটি ফাঁকা ছবি তৈরি করে৷
-
$পয়েন্ট − বহুভুজের অনুক্রমিক শীর্ষবিন্দু ধরে রাখে।
-
$num_points - একটি বহুভুজের মোট শীর্ষবিন্দুর সংখ্যা ধারণ করে। একটি বহুভুজ তৈরি করতে মোট বিন্দু/বিন্দুর সংখ্যা কমপক্ষে তিনটি হতে হবে।
-
$color − imagecolorallocate() ফাংশন ব্যবহার করে ভরা রঙ শনাক্তকারী রয়েছে।
রিটার্ন মান
এটি সাফল্যের উপর সত্য এবং ব্যর্থতার উপর মিথ্যা ফেরত দেয়।
উদাহরণ 1
<?php
// set up array of points for a polygon
$values = array(
40, 50, // Point 1 (x, y)
20, 240, // Point 2 (x, y)
60, 60, // Point 3 (x, y)
240, 20, // Point 4 (x, y)
50, 40, // Point 5 (x, y)
10, 10 // Point 6 (x, y)
);
// create the image using imagecreatetruecolor function
$img = imagecreatetruecolor(700, 350);
// allocated the blue and gray colors
$bg = imagecolorallocate($img, 122, 122, 122);
$blue = imagecolorallocate($img, 0, 0, 255);
// filled the background
imagefilledrectangle($img, 0, 0, 350, 350, $bg);
// draw a polygon
imagefilledpolygon($img, $values, 6, $blue);
// flush image
header('Content-type: image/png');
imagepng($img);
imagedestroy($img);
?> আউটপুট

উদাহরণ 2
<?php
// Set the vertices of the polygon
$values = array(
150, 50, // Point 1 (x, y)
55, 119, // Point 2 (x, y)
91, 231, // Point 3 (x, y)
209, 231, // Point 4 (x, y)
245, 119 // Point 5 (x, y)
);
// It creates the size of the image or blank image.
$img = imagecreatetruecolor(700, 350);
// Set the gray background image color
$bg = imagecolorallocate($img, 122, 122, 122);
// Set the red image color
$red = imagecolorallocate($img, 255, 0, 0);
// fill the background
imagefilledrectangle($img, 0, 0, 350, 350, $bg);
// Draw the polygon image
imagefilledpolygon($img, $values, 5, $red);
// Output of the image.
header('Content-type: image/png');
imagepng($img);
imagedestroy($img);
?> আউটপুট
