Initial commit
This commit is contained in:
@@ -0,0 +1,129 @@
|
||||
<?php
|
||||
/*=========================================================================*/
|
||||
/* Name: ClipCircle.php */
|
||||
/* Uses: Draw a circle clipped within boundaries */
|
||||
/* Date: 1/1/2008 */
|
||||
/* Author: Andrew Que (http://www.DrQue.net/) */
|
||||
/* Revisions: */
|
||||
/* 1.0 - 1/1/2008 - QUE - Creatuib */
|
||||
/* */
|
||||
/* ----------------------------------------------------------------------- */
|
||||
/* */
|
||||
/* X/Y trend with linear regression script */
|
||||
/* Copyright (C) 2008 Andrew Que */
|
||||
/* */
|
||||
/* This program is free software: you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation, either version 3 of the License, or */
|
||||
/* (at your option) any later version. */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/* ----------------------------------------------------------------------- */
|
||||
/* */
|
||||
/* (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
|
||||
*
|
||||
* <p>
|
||||
* Draw a filled circle and do not allow it to extend byond a defined set of
|
||||
* boundaries.
|
||||
* <p>
|
||||
* 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 );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user