error_reporting(0);
include("functions.php");
$h1 = "DJ Mike's Image Maker 2";
$h2 = "Ellipses";
##
if ( $_GET[action] == "Reset" )
{
$_SESSION[fill_alpha] = NULL;
$_SESSION[fill_opacity] = NULL;
$_SESSION[stroke_alpha] = NULL;
$_SESSION[stroke_opacity] = NULL;
$_SESSION[stroke_color] = NULL;
$_SESSION[fill_color] = NULL;
$_SESSION[stroke_width] = NULL;
header("location:$self");
exit;
}
# set stroke alpha
if ($_GET[stroke_alpha])
{
$stroke_alpha = trim($_GET[stroke_alpha] );
$stroke_alpha = (float)$stroke_alpha;
if ( $stroke_alpha < 0 ) { $stroke_alpha = 0; }
if ( $stroke_alpha > 1 ) { $stroke_alpha = 1; }
}
# set stroke opacity
if ($_GET[stroke_opacity])
{
$stroke_opacity = trim($_GET[stroke_opacity] );
$stroke_opacity = (float)$stroke_opacity;
if ( $stroke_opacity < 0 ) { $stroke_opacity = 0; }
if ( $stroke_opacity > 1 ) { $stroke_opacity = 1; }
}
# set stroke fill opacity
if ($_GET[fill_opacity])
{
$fill_opacity = trim($_GET[fill_opacity] );
$fill_opacity = (float)$fill_opacity;
if ( $fill_opacity < 0 ) { $fill_opacity = 0; }
if ( $fill_opacity > 1 ) { $fill_opacity = 1; }
}
# set stroke fill alpha
if ($_GET[fill_alpha])
{
$fill_alpha = trim($_GET[fill_alpha] );
$fill_alpha = (float)$fill_alpha;
if ( $fill_alpha < 0 ) { $fill_alpha = 0; }
if ( $fill_alpha > 1 ) { $fill_alpha = 1; }
}
#### validate color ##
if ( $_GET[fill_color] )
{
$fill_color = trim($_GET[fill_color] );
$fill_color = colors( $fill_color, "validate" );
if ( !$fill_color )
{ $error .= "Fill color is invalid
"; }
}
##
if ( $_GET[stroke_color] )
{
$stroke_color = trim($_GET[stroke_color] );
$stroke_color = colors( $stroke_color, "validate" );
if ( !$stroke_color )
{ $error .= "Stroke color is invalid
"; }
}
if ( $error )
{
$_SESSION[error] = $error;
header("location:$self");
}
#### end validate colors ##
#### if all vars set, make image & draw object
$image = new Imagick($_SESSION[path]);
$draw = new ImagickDraw;
$ellipse_start = (float)$_GET[ellipse_start];
$ellipse_end = (float)$_GET[ellipse_end];
$skewX = (float)$_GET[draw_skew_x];
$skewY = (float)$_GET[draw_skew_y];
$scaleX = (float)$_GET[draw_scale_x];
$scaleY = (float)$_GET[draw_scale_y];
if ( $scaleX == 0 ) { $scaleX = 1; }
$scaleY = (float)$_GET[draw_scale_y];
if ( $scaleY == 0 ) { $scaleY = 1; }
$deg = (float)$_GET[draw_rotate];
if ( $_GET[ul_x] &&
$_GET[ul_y] &&
$_GET[w] &&
$_GET[h] &&
$_SESSION[path] &&
$_GET[action] == "Draw Ellipse" )
{
$ul_x = (int)$_GET[ul_x];
$ul_y = (int)$_GET[ul_y];
$w = (float)$_GET[w];
$h = (float)$_GET[h];
$w = abs($w);
$h = abs($h);
# set colors
if ( $fill_color ) { $draw->setfillcolor("$fill_color"); }
if ( $stroke_color ) { $draw->setstrokecolor($stroke_color); }
# set width
$stroke_width = trim($_GET[stroke_width] );
$stroke_width = (int)$stroke_width;
if ( $stroke_width ) { $draw->setstrokewidth($stroke_width); }
# set stroke alpha/opacity & fill alpha/opacity
if ( $stroke_alpha ) { $draw->setstrokealpha($stroke_alpha); }
if ( $stroke_opacity ) { $draw->setstrokealpha($stroke_opacity); }
if ( $fill_opacity ) { $draw->setfillalpha($fill_opacity); }
if ( $fill_alpha ) { $draw->setfillalpha($fill_alpha); }
$draw->skewx($skewX);
$draw->skewy($skewY);
$draw->rotate($deg);
$draw->scale( $scaleX, $scaleY );
# set line cap
switch ($_GET[line_cap])
{
case "BUTT";
$cap = imagick::LINECAP_BUTT;
break;
case "ROUND";
$cap = imagick::LINECAP_ROUND;
break;
case "SQUARE";
$cap = imagick::LINECAP_SQUARE;
break;
default:
$cap = imagick::LINECAP_UNDEFINED;
}
$draw->setStrokeLineCap($cap);
########## draw Ellipse #########
if ( $_GET[action] == "Draw Ellipse" )
{
$draw->ellipse( $ul_x,$ul_y, $w, $h, $ellipse_start, $ellipse_end);
foreach ($image as $frame) { $frame->drawimage($draw); }
}
############################
$format = strtolower( $image->getimageformat() );
$path = "temp/$ID.$_SESSION[views].$format";
$frames = $image->getNumberImages();
if ( $frames > 1) { $image->writeImages("$path", TRUE); }
else { $image->writeImage("$path"); }
# save settings
$_SESSION[ellipse_start] = $ellipse_start;
$_SESSION[ellipse_end] = $ellipse_end;
$_SESSION[draw_scale_x] = $scaleX;
$_SESSION[draw_scale_y] = $scaleY;
$_SESSION[stroke_width] = $stroke_width;
$_SESSION[fill_alpha] = $fill_alpha;
$_SESSION[fill_opacity] = $fill_opacity;
$_SESSION[stroke_alpha] = $stroke_alpha;
$_SESSION[stroke_opacity] = $stroke_opacity;
$_SESSION[path] = $path;
$_SESSION[fill_color] = $fill_color;
$_SESSION[stroke_color] = $stroke_color;
$_SESSION[x_round] = $x_round;
$_SESSION[y_round] = $y_round;
$_SESSION[draw_rotate] = $deg;
$_SESSION[draw_skew_x] = $skewX;
$_SESSION[draw_skew_y] = $skewY;
header("Location: display.php");
exit;
# end draw
}
############ step 2
# if 2nd coorids not set, set var for form
if ( $_GET[crop_image_x] && $_GET[crop_image_y] &&
$_GET[ul_x] && $_GET[ul_y] &&
!$_GET[lr_x] && !$_GET[lr_y]
)
{
$ul_x = $_GET[ul_x];
$ul_y = $_GET[ul_y];
$lr_x = $_GET[crop_image_x];
$lr_y = $_GET[crop_image_y];
$ellipse_width = abs($lr_x-$ul_x);
$ellipse_height = abs($lr_y-$ul_y);
header("location:$self?ul_x=$ul_x&ul_y=$ul_y&w=$ellipse_width&h=$ellipse_height");
exit;
}
# Step 1.
# Vars shouldn't be set at this point
# if 1st coorids not set, set vars for form
if ($_GET[crop_image_x] && $_GET[crop_image_y] &&
!$_GET[ul_x] &&
!$_GET[ul_x] &&
!$_GET[lr_x] &&
!$_GET[lr_x]
)
{
$ul_x = $_GET[crop_image_x];
$ul_y = $_GET[crop_image_y];
header("location:$self?ul_x=$ul_x&ul_y=$ul_y");
exit;
}
?>
include("style.txt"); ?>
echo "$h1: $h2"; ?>
=$h1; ?>
include("nav.php"); ?>
=$h2; ?>
if ( $_SESSION[error] )
{
echo "$_SESSION[error]";
$_SESSION[error] = NULL;
}
?>
if ( !isset($_SESSION[path]) )
{
echo "";
echo "No image";
echo "
";
}
if ( isset($_SESSION[path]) )
{
echo "";
}
?>
Ellipses
Arcs are described by a center point, a width, a height a starting angle and an end angle.
Instructions
- Click center of ellipse
or
Enter the x,y cooridinates of center of ellipse
-
Click a corner of the bounding box of the ellipse and the width and height will be calculated for you
or
Enter the width and height
- Enter starting angle.
- Enter end angle.
-
- Enter Stroke Color. Can be valid color name or hex.
- Enter Stroke Width. (optional)
- Select Line Cap style for lines. (optional)
- Enter Fill Color for shapes. Can be valid color name or hex.(optional).
- Enter Stroke Opacity. Range: 0-1 (optional)
- Enter Stroke Alpha. Range: 0-1 (optional)
- Enter Fill Opacity. Range: 0-1 (optional)
- Enter Fill Alpha. Range: 0-1 (optional)
- Click Make Ellipse.
- Your settings (except for cooridinates) will be saved. Clicking Reset will delete your settings
Fill Color
The color Inside the ellipse
Stroke Color
The color of the lines
- Stroke Width
- The thickness of the lines
- Line Cap
- How the lines end.
- Stroke Alpha
-
- Fill Alpha
- Fill Alpha
-
- Fill Opacity
- Rotate
- Rotate draw object
- Skew
- Skews the shape. Enter degrees of skew.
- Scale
- Stretch the shape. 1 for unchanged. 2 to double etc
/*
*/
?>
include("footer.php");
?>