php imagefilledpolygon,imagefilledpolygon

[#6]

tatlar at yahoo dot com [2006-09-11 17:08:22]

// $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.?>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值