|
imagesetstyle
Set the style for line drawing
(PHP 4 >= 4.0.6, PHP 5)
Example 1022. imagesetstyle() example<?php The above example will output something similar to: Code Examples / Notes » imagesetstylecruz
When lines drawn with imagesetstyle seem to produce a thin white line only, make sure antialiasing is disabled. <? imageantialias($im, false); $style = array($gridxcolor, $gridxcolor, IMG_COLOR_TRANSPARENT, IMG_COLOR_TRANSPARENT); imagesetstyle($im, $style); imageline($im, $x, 0, $x, $ymax+5, IMG_COLOR_STYLED); imageantialias($im, true); ?> Setstyle and Antialias don't go together. yhoko
When drawing lines that are >1px thick you'll have to setup the array corresponding to this fact (since there's no multi-array support for this function). For example if the line's 3 pixels thick each 2nd color goes to the 2nd line, each 3rd color to the 3rd line and so on. michael_todd_335
Watch out! If you pass imagesetstyle() an empty array as the second argument, it will crash your server! I was messing with it just earlier and accidentally did so, and the page took a good minute to process, when my Apache server came up with the good ol' Windows 'Send Error Report' window. zackbloom
Use this to set the style to any combination of pixels. You can pass as many modifiers as you wish. Use the format [num]r[red]g[green]b[blue]. For example: $im=dashed($im,"4r255g0b0","2r0g255b0","5r0g0b255"); imageline($im, 0, 0, 600, 600, IMG_COLOR_STYLED); function dashed($im){ $size = func_num_args(); for($i = 0; $i < $size; $i++){ $arg = func_get_arg($i); if(!is_resource($arg)){ $r=substr($arg,strpos($arg,"r")+1, strpos($arg,"g")-strpos($arg,"r")-1); $g=substr($arg,strpos($arg,"g")+1, strpos($arg,"b")-strpos($arg,"g")-1); $b=substr($arg,strpos($arg,"b")+1, strlen($arg)-strpos($arg,"b")); $color = imagecolorallocate($im,$r,$g,$b); $x = substr($arg,0,strpos($arg,"r")); $vals[$i] = array_fill(0,$x,$color); } } for($k=0;$k<count($vals)+1;$k++) if(array_key_exists($k,$vals)) $prop=array_merge($prop,$vals[$k]); imagesetstyle($im, $prop); return $im; } |
Change Languagegd_info getimagesize image_type_to_extension image_type_to_mime_type image2wbmp imagealphablending imageantialias imagearc imagechar imagecharup imagecolorallocate imagecolorallocatealpha imagecolorat imagecolorclosest imagecolorclosestalpha imagecolorclosesthwb imagecolordeallocate imagecolorexact imagecolorexactalpha imagecolormatch imagecolorresolve imagecolorresolvealpha imagecolorset imagecolorsforindex imagecolorstotal imagecolortransparent imageconvolution imagecopy imagecopymerge imagecopymergegray imagecopyresampled imagecopyresized imagecreate imagecreatefromgd2 imagecreatefromgd2part imagecreatefromgd imagecreatefromgif imagecreatefromjpeg imagecreatefrompng imagecreatefromstring imagecreatefromwbmp imagecreatefromxbm imagecreatefromxpm imagecreatetruecolor imagedashedline imagedestroy imageellipse imagefill imagefilledarc imagefilledellipse imagefilledpolygon imagefilledrectangle imagefilltoborder imagefilter imagefontheight imagefontwidth imageftbbox imagefttext imagegammacorrect imagegd2 imagegd imagegif imagegrabscreen imagegrabwindow imageinterlace imageistruecolor imagejpeg imagelayereffect imageline imageloadfont imagepalettecopy imagepng imagepolygon imagepsbbox imagepsencodefont imagepsextendfont imagepsfreefont imagepsloadfont imagepsslantfont imagepstext imagerectangle imagerotate imagesavealpha imagesetbrush imagesetpixel imagesetstyle imagesetthickness imagesettile imagestring imagestringup imagesx imagesy imagetruecolortopalette imagettfbbox imagettftext imagetypes imagewbmp imagexbm iptcembed iptcparse jpeg2wbmp png2wbmp |