note 69586 added to function.imagefilledpolygon

From: Date: Tue, 12 Sep 2006 00:08:22 +0000
Subject: note 69586 added to function.imagefilledpolygon
Groups: php.notes 
Request: Send a blank email to php-notes+get-117036@lists.php.net to get a copy of this message
<?php function _makeFiveSidedStar( $x, $y, $radius, $shape='polygon', $spiky=NULL ) { // $x, $y co-ords of origin (in pixels), $radius (in pixels), $shape - 'polygon' or 'star', $spikiness - ratio between 0 and 1 $point = array() ; $angle = 360 / 5 ; $point[0]['x'] = $x ; $point[0]['y'] = $y - $radius ; $point[2]['x'] = $x + ( $radius * cos( deg2rad( 90 - $angle ) ) ) ; $point[2]['y'] = $y - ( $radius * sin( deg2rad( 90 - $angle ) ) ) ; $point[4]['x'] = $x + ( $radius * sin( deg2rad( 180 - ( $angle*2 ) ) ) ) ; $point[4]['y'] = $y + ( $radius * cos( deg2rad( 180 - ( $angle*2 ) ) ) ) ; $point[6]['x'] = $x - ( $radius * sin( deg2rad( 180 - ( $angle*2 ) ) ) ) ; $point[6]['y'] = $y + ( $radius * cos( deg2rad( 180 - ( $angle*2 ) ) ) ) ; $point[8]['x'] = $x - ( $radius * cos( deg2rad( 90 - $angle ) ) ) ; $point[8]['y'] = $y - ( $radius * sin( deg2rad( 90 - $angle ) ) ) ; if( $shape == 'star' ) { if( $spiky == NULL ) $spiky = 0.5 ; // default to 0.5 $indent = $radius * $spiky ; $point[1]['x'] = $x + ( $indent * cos( deg2rad( 90 - $angle/2 ) ) ) ; $point[1]['y'] = $y - ( $indent * sin( deg2rad( 90 - $angle/2 ) ) ) ; $point[3]['x'] = $x + ( $indent * sin( deg2rad( 180 - $angle ) ) ) ; $point[3]['y'] = $y - ( $indent * cos( deg2rad( 180 - $angle ) ) ) ; $point[5]['x'] = $x ; $point[5]['y'] = $y + ( $indent * sin( deg2rad( 180 - $angle ) ) ) ; $point[7]['x'] = $x - ( $indent * sin( deg2rad( 180 - $angle ) ) ) ; $point[7]['y'] = $y - ( $indent * cos( deg2rad( 180 - $angle ) ) ) ; $point[9]['x'] = $x - ( $indent * cos( deg2rad( 90 - $angle/2 ) ) ) ; $point[9]['y'] = $y - ( $indent * sin( deg2rad( 90 - $angle/2 ) ) ) ; } ksort( $point ) ; $coords = array() ; // new array foreach( $point as $pKey=>$pVal ) { if( is_array( $pVal ) ) { foreach( $pVal as $pSubKey=>$pSubVal ) { if( !empty( $pSubVal ) ) array_push( $coords, $pSubVal ) ; } } } return $coords ; } $values = _makeFiveSidedStar( 100, 100, 50, 'star' ) ; // Put values into imagepolygon function. You need to define the $image and $color, and flush it out to an image type.?> ---- Server IP: 216.194.113.175 Probable Submitter: 209.193.47.96 ---- Manual Page -- http://www.php.net/manual/en/function.imagefilledpolygon.php Edit -- https://master.php.net/note/edit/69586 Del: integrated -- https://master.php.net/note/delete/69586/integrated Del: useless -- https://master.php.net/note/delete/69586/useless Del: bad code -- https://master.php.net/note/delete/69586/bad+code Del: spam -- https://master.php.net/note/delete/69586/spam Del: non-english -- https://master.php.net/note/delete/69586/non-english Del: in docs -- https://master.php.net/note/delete/69586/in+docs Del: other reasons-- https://master.php.net/note/delete/69586 Reject -- https://master.php.net/note/reject/69586 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#117036) next »