imagesetstyle() PHP में एक अंतर्निहित फ़ंक्शन है जिसका उपयोग लाइन ड्राइंग के लिए स्टाइल सेट करने के लिए किया जाता है। इसका उपयोग imagepolygon या imageline जैसे सभी लाइन ड्राइंग फ़ंक्शन्स द्वारा किया जा सकता है।
सिंटैक्स
bool imagesetstyle(resource $image, array $style)
पैरामीटर्स
imagesetstyle() दो पैरामीटर्स लेता है: $image और $style।
$image - काम करने के लिए इमेज रिसोर्स निर्दिष्ट करता है।
$style - पिक्सेल रंगों के ऐरे को निर्दिष्ट करता है।
रिटर्न वैल्यूज़
imagesetstyle() सफलता पर True या विफलता पर False लौटाता है।
उदाहरण 1
<?php
header("Content-type: image/jpeg");
$img = imagecreatetruecolor(700, 300);
$w = imagecolorallocate($img, 122, 122, 122);
$red = imagecolorallocate($img, 255, 0, 0);
/* एक डैश्ड लाइन ड्रा करें, 5 लाल पिक्सेल, 5 सफेद पिक्सेल */
$style = array($red, $red, $red, $red, $red, $w, $w, $w, $w, $w);
imagesetstyle($img, $style);
imageline($img, 0, 0, 200, 200, IMG_COLOR_STYLED);
/* imagesetbrush() के साथ imagesetstyle का उपयोग करके हैप्पी फेसेस की लाइन ड्रा करें */
$style = array($w, $w, $w, $w, $w, $w, $w, $w, $w, $w, $w, $w, $red);
imagesetstyle($img, $style);
$brush = imagecreatefrompng('C:\xampp\htdocs\Images\img34.png');
$w2 = imagecolorallocate($brush, 255, 255, 255);
imagecolortransparent($brush, $w2);
imagesetbrush($img, $brush);
imageline($img, 200, 0, 0, 200, IMG_COLOR_STYLEDBRUSHED);
imagejpeg($img);
imagedestroy($img);
?>
इनपुट इमेज

आउटपुट इमेज

उदाहरण 2
<?php
// imagecreatefrompng() फ़ंक्शन का उपयोग करके PNG इमेज लोड करें
$img = imagecreatefrompng('C:\xampp\htdocs\Images\img34.png');
// नीले और हरे रंग आवंटित करें
$blue = imagecolorallocate($img, 0, 0, 255);
$green = imagecolorallocate($img, 0, 255, 0);
// एक डैश्ड लाइन ड्रा करें, 5 नीले पिक्सेल, 5 सफेद पिक्सेल
$style = array($blue, $blue, $blue, $blue, $blue, $green, $green, $green, $green, $green);
imagesetstyle($img, $style);
imageline($img, 0, 100, 800, 100, IMG_COLOR_STYLED);
// ब्राउज़र को इमेज आउटपुट करें
header('Content-type: image/png');
imagepng($img);
?>
आउटपुट
