. */ /* */ /* ----------------------------------------------------------------------- */ /* */ /* (C) Copyright 2008 */ /* Andrew Que */ /* ð|> */ /*=========================================================================*/ /** * Clip circle * * Contains a function to draw a circle clipped within boundaries * @package XY_Plot * @author Andrew Que ({@link http://www.DrQue.net/}) * @copyright Copyright (c) 2008, Andrew Que * @license http://opensource.org/licenses/gpl-license.php GNU Public License * */ /** * Draw a circle with clipping * *

* Draw a filled circle and do not allow it to extend byond a defined set of * boundaries. *

* This isn't the most efficent implementation, so don't use when speed is * essential * @param $Image Image to draw circle onto * @param $CenterX X-coordinate of center of circle * @param $CenterY Y-coordinate of center of circle * @param $Diameter Diameter of circle * @param $Color Color of circle * @param $ClipLeft Left boundary * @param $ClipTop Top boundary * @param $ClipRight Right boundary * @param $ClipBottom Bottom doundary */ function ClippedFilledCircle( $Image , $CenterX , $CenterY , $Diameter , $Color , $ClipLeft = null , $ClipTop = null , $ClipRight = null , $ClipBottom = null ) { $Radius = $Diameter / 2.0; $Count = round( -$Radius ); while ( $Count <= $Radius ) { $y = $CenterY + $Count; $yy = $CenterY + $Count; $Delta = ( $Radius * $Radius ) - ( $Count * $Count ); ++$Count; if ( $Delta < 0 ) continue; $Delta = sqrt( $Delta ); $x = ceil( $CenterX - $Delta ); $xx = floor( $CenterX + $Delta ); // Above the top margin? if ( ( $ClipTop !== null ) && ( $y < $ClipTop ) ) continue; // Below the bottm margin? if ( ( $ClipBottom !== null ) && ( $yy > $ClipBottom ) ) continue; // Byond left margin? if ( ( $ClipLeft !== null ) && ( $x < $ClipLeft ) ) $x = $ClipLeft; // Byond right margin? if ( ( $ClipRight !== null ) && ( $xx > $ClipRight ) ) $xx = $ClipRight; // Off the chat? if ( ( $ClipLeft !== null ) && ( $xx < $ClipLeft ) ) continue; if ( ( $ClipLeft !== null ) && ( $x > $ClipRight ) ) continue; // Draw line ImageLine( $Image , $x , $y , $xx , $y , $Color ); } } ?>