ImagickDraw::circle
(No version information available, might be only in CVS)
ImagickDraw::circle — Draws a circle
Описание
bool ImagickDraw::circle
( float $ox
, float $oy
, float $px
, float $py
)
Внимание
К настоящему времени эта функция еще не была документирована; для ознакомления доступен только список аргументов.
Draws a circle on the image.
Список параметров
- ox
-
origin x coordinate
- oy
-
origin y coordinate
- px
-
perimeter x coordinate
- py
-
perimeter y coordinate
Возвращаемые значения
Эта функция не возвращает значения после выполнения.
- PHP Руководство
- Функции по категориям
- Индекс функций
- Справочник функций
- Обработка и генерация изображений
- Обработка изображений (ImageMagick)
- Функция ImagickDraw::affine() - Adjusts the current affine transformation matrix
- Функция ImagickDraw::annotation() - Draws text on the image
- Функция ImagickDraw::arc() - Draws an arc
- Функция ImagickDraw::bezier() - Draws a bezier curve
- Функция ImagickDraw::circle() - Draws a circle
- Функция ImagickDraw::clear() - Clears the ImagickDraw
- Функция ImagickDraw::clone() - Makes an exact copy of the specified ImagickDraw object
- Функция ImagickDraw::color() - Draws color on image
- Функция ImagickDraw::comment() - Adds a comment
- Функция ImagickDraw::composite() - Composites an image onto the current image
- Функция ImagickDraw::__construct() - The ImagickDraw constructor
- Функция ImagickDraw::destroy() - Frees all associated resources
- Функция ImagickDraw::ellipse() - Draws an ellipse on the image
- Функция ImagickDraw::getClipPath() - Obtains the current clipping path ID
- Функция ImagickDraw::getClipRule() - Returns the current polygon fill rule
- Функция ImagickDraw::getClipUnits() - Returns the interpretation of clip path units
- Функция ImagickDraw::getFillColor() - Returns the fill color
- Функция ImagickDraw::getFillOpacity() - Returns the opacity used when drawing
- Функция ImagickDraw::getFillRule() - Returns the fill rule
- Функция ImagickDraw::getFont() - Returns the font
- Функция ImagickDraw::getFontFamily() - Returns the font family
- Функция ImagickDraw::getFontSize() - Returns the font pointsize
- ImagickDraw::getFontStretch
- Функция ImagickDraw::getFontStyle() - Returns the font style
- Функция ImagickDraw::getFontWeight() - Returns the font weight
- Функция ImagickDraw::getGravity() - Returns the text placement gravity
- Функция ImagickDraw::getStrokeAntialias() - Returns the current stroke antialias setting
- Функция ImagickDraw::getStrokeColor() - Returns the color used for stroking object outlines
- Функция ImagickDraw::getStrokeDashArray() - Returns an array representing the pattern of dashes and gaps used to stroke paths
- Функция ImagickDraw::getStrokeDashOffset() - Returns the offset into the dash pattern to start the dash
- Функция ImagickDraw::getStrokeLineCap() - Returns the shape to be used at the end of open subpaths when they are stroked
- Функция ImagickDraw::getStrokeLineJoin() - Returns the shape to be used at the corners of paths when they are stroked
- Функция ImagickDraw::getStrokeMiterLimit() - Returns the stroke miter limit
- Функция ImagickDraw::getStrokeOpacity() - Returns the opacity of stroked object outlines
- Функция ImagickDraw::getStrokeWidth() - Returns the width of the stroke used to draw object outlines
- Функция ImagickDraw::getTextAlignment() - Returns the text alignment
- Функция ImagickDraw::getTextAntialias() - Returns the current text antialias setting
- Функция ImagickDraw::getTextDecoration() - Returns the text decoration
- Функция ImagickDraw::getTextEncoding() - Returns the code set used for text annotations
- ImagickDraw::getTextInterlineSpacing
- ImagickDraw::getTextInterwordSpacing
- ImagickDraw::getTextKerning
- Функция ImagickDraw::getTextUnderColor() - Returns the text under color
- Функция ImagickDraw::getVectorGraphics() - Returns a string containing vector graphics
- Функция ImagickDraw::line() - Draws a line
- Функция ImagickDraw::matte() - Paints on the image's opacity channel
- Функция ImagickDraw::pathClose() - Adds a path element to the current path
- Функция ImagickDraw::pathCurveToAbsolute() - Draws a cubic Bezier curve
- Функция ImagickDraw::pathCurveToQuadraticBezierAbsolute() - Draws a quadratic Bezier curve
- Функция ImagickDraw::pathCurveToQuadraticBezierRelative() - Draws a quadratic Bezier curve
- Функция ImagickDraw::pathCurveToQuadraticBezierSmoothAbsolute() - Draws a quadratic Bezier curve
- Функция ImagickDraw::pathCurveToQuadraticBezierSmoothRelative() - Draws a quadratic Bezier curve
- Функция ImagickDraw::pathCurveToRelative() - Draws a cubic Bezier curve
- Функция ImagickDraw::pathCurveToSmoothAbsolute() - Draws a cubic Bezier curve
- Функция ImagickDraw::pathCurveToSmoothRelative() - Draws a cubic Bezier curve
- Функция ImagickDraw::pathEllipticArcAbsolute() - Draws an elliptical arc
- Функция ImagickDraw::pathEllipticArcRelative() - Draws an elliptical arc
- Функция ImagickDraw::pathFinish() - Terminates the current path
- Функция ImagickDraw::pathLineToAbsolute() - Draws a line path
- Функция ImagickDraw::pathLineToHorizontalAbsolute() - Draws a horizontal line path
- Функция ImagickDraw::pathLineToHorizontalRelative() - Draws a horizontal line
- Функция ImagickDraw::pathLineToRelative() - Draws a line path
- Функция ImagickDraw::pathLineToVerticalAbsolute() - Draws a vertical line
- Функция ImagickDraw::pathLineToVerticalRelative() - Draws a vertical line path
- Функция ImagickDraw::pathMoveToAbsolute() - Starts a new sub-path
- Функция ImagickDraw::pathMoveToRelative() - Starts a new sub-path
- Функция ImagickDraw::pathStart() - Declares the start of a path drawing list
- Функция ImagickDraw::point() - Draws a point
- Функция ImagickDraw::polygon() - Draws a polygon
- Функция ImagickDraw::polyline() - Draws a polyline
- Функция ImagickDraw::pop() - Destroys the current ImagickDraw in the stack, and returns to the previously pushed ImagickDraw
- Функция ImagickDraw::popClipPath() - Terminates a clip path definition
- Функция ImagickDraw::popDefs() - Terminates a definition list
- Функция ImagickDraw::popPattern() - Terminates a pattern definition
- Функция ImagickDraw::push() - Clones the current ImagickDraw and pushes it to the stack
- Функция ImagickDraw::pushClipPath() - Starts a clip path definition
- Функция ImagickDraw::pushDefs() - Indicates that following commands create named elements for early processing
- Функция ImagickDraw::pushPattern() - Indicates that subsequent commands up to a ImagickDraw::opPattern() command comprise the definition of a named pattern
- Функция ImagickDraw::rectangle() - Draws a rectangle
- Функция ImagickDraw::render() - Renders all preceding drawing commands onto the image
- ImagickDraw::resetVectorGraphics
- Функция ImagickDraw::rotate() - Applies the specified rotation to the current coordinate space
- Функция ImagickDraw::roundRectangle() - Draws a rounded rectangle
- Функция ImagickDraw::scale() - Adjusts the scaling factor
- Функция ImagickDraw::setClipPath() - Associates a named clipping path with the image
- Функция ImagickDraw::setClipRule() - Set the polygon fill rule to be used by the clipping path
- Функция ImagickDraw::setClipUnits() - Sets the interpretation of clip path units
- Функция ImagickDraw::setFillAlpha() - Sets the opacity to use when drawing using the fill color or fill texture
- Функция ImagickDraw::setFillColor() - Sets the fill color to be used for drawing filled objects
- Функция ImagickDraw::setFillOpacity() - Sets the opacity to use when drawing using the fill color or fill texture
- Функция ImagickDraw::setFillPatternURL() - Sets the URL to use as a fill pattern for filling objects
- Функция ImagickDraw::setFillRule() - Sets the fill rule to use while drawing polygons
- Функция ImagickDraw::setFont() - Sets the fully-specified font to use when annotating with text
- Функция ImagickDraw::setFontFamily() - Sets the font family to use when annotating with text
- Функция ImagickDraw::setFontSize() - Sets the font pointsize to use when annotating with text
- Функция ImagickDraw::setFontStretch() - Sets the font stretch to use when annotating with text
- Функция ImagickDraw::setFontStyle() - Sets the font style to use when annotating with text
- Функция ImagickDraw::setFontWeight() - Sets the font weight
- Функция ImagickDraw::setGravity() - Sets the text placement gravity
- ImagickDraw::setResolution
- Функция ImagickDraw::setStrokeAlpha() - Specifies the opacity of stroked object outlines
- Функция ImagickDraw::setStrokeAntialias() - Controls whether stroked outlines are antialiased
- Функция ImagickDraw::setStrokeColor() - Sets the color used for stroking object outlines
- Функция ImagickDraw::setStrokeDashArray() - Specifies the pattern of dashes and gaps used to stroke paths
- Функция ImagickDraw::setStrokeDashOffset() - Specifies the offset into the dash pattern to start the dash
- Функция ImagickDraw::setStrokeLineCap() - Specifies the shape to be used at the end of open subpaths when they are stroked
- Функция ImagickDraw::setStrokeLineJoin() - Specifies the shape to be used at the corners of paths when they are stroked
- Функция ImagickDraw::setStrokeMiterLimit() - Specifies the miter limit
- Функция ImagickDraw::setStrokeOpacity() - Specifies the opacity of stroked object outlines
- Функция ImagickDraw::setStrokePatternURL() - Sets the pattern used for stroking object outlines
- Функция ImagickDraw::setStrokeWidth() - Sets the width of the stroke used to draw object outlines
- Функция ImagickDraw::setTextAlignment() - Specifies a text alignment
- Функция ImagickDraw::setTextAntialias() - Controls whether text is antialiased
- Функция ImagickDraw::setTextDecoration() - Specifies a decoration
- Функция ImagickDraw::setTextEncoding() - Specifies specifies the text code set
- ImagickDraw::setTextInterlineSpacing
- ImagickDraw::setTextInterwordSpacing
- ImagickDraw::setTextKerning
- Функция ImagickDraw::setTextUnderColor() - Specifies the color of a background rectangle
- Функция ImagickDraw::setVectorGraphics() - Sets the vector graphics
- Функция ImagickDraw::setViewbox() - Sets the overall canvas size
- Функция ImagickDraw::skewX() - Skews the current coordinate system in the horizontal direction
- Функция ImagickDraw::skewY() - Skews the current coordinate system in the vertical direction
- Функция ImagickDraw::translate() - Applies a translation to the current coordinate system
Коментарии
This example creates a circle, one part green, one part red using kind of masks for transparency, which you might know from Photoshop. drawImage() is a quick helper for debug output (see code comments) to help you reproduce the process.
<?php
function drawImage(Imagick $im) {
$im->setCompressionQuality(100);
$im->setImageFormat("jpg");
header("Content-Type: image/" . $im->getImageFormat());
echo $im;
exit;
}
// define red/green layer
$layer1 = new Imagick();
$layer1->newImage(100, 100, "none");
$red = new ImagickDraw();
$red->setFillColor("#FF0000");
$red->rectangle(0, 0, 50, 100);
$green = new ImagickDraw();
$green->setFillColor("#00FF00");
$green->rectangle(50, 0, 100, 100);
$layer1->drawImage($red);
$layer1->drawImage($green);
# debug output: two rectangles
# drawImage($layer1);
// define circle mask
$layer2 = new Imagick();
$layer2->newImage(100, 100, "none");
$circle = new ImagickDraw();
$circle->setFillColor("#FFFFFF");
$circle->circle(50, 50, 48, 98);
$layer2->drawImage($circle);
# debug output: the mask
# drawImage($layer2);
// use mask
$layer1->compositeImage($layer2, Imagick::COMPOSITE_DSTIN, 0, 0);
# debug output: the result of our mask usage
# drawImage($layer1);
// define background
$layer3 = new Imagick();
$layer3->newImage(100, 100, "none");
$layer3->compositeImage($layer1, Imagick::COMPOSITE_DEFAULT, 0, 0);
// define ring as background
$layer4 = new Imagick();
$layer4->newImage(100, 100, "white"); // this is our background
$ring1 = new ImagickDraw();
$ring1->setFillColor("black");
$ring1->circle(50, 50, 50, 99);
$layer4->drawImage($ring1);
# debug output: this is a black circle (not our mask, which is similar, but a little bit smaller)
# drawImage($layer4);
// use black circle as background (this creates our circle border)
$layer4->compositeImage($layer3, Imagick::COMPOSITE_DEFAULT, 0, 0);
# debug output: here we go with our circle border
# drawImage($layer4);
// draw separator between red and green rectangle (now semi circles)
$line = new ImagickDraw();
$line->setStrokeWidth(1);
$line->setStrokeColor("black");
$line->line(50, 1, 50, 99);
// add our separator line
$layer4->drawImage($line);
drawImage($layer4);
?>
To understand how the COMPOSITE_* constants effect the image merging process, see here:
http://www.imagemagick.org/Usage/compose/#duff-porter
<?php
// OR we could just draw a simple circle for the benefit of the newbies.
// I'm not great at OOP programming and I hope my comments are accurate.
// commets or criticism are welcome.
$image = new Imagick(); // Create a new instance an $image class
$width = 600; // Some necessary dimensions
$height = 400;
// $image class now inherits some attributes. i.e. Dimensions, bkgcolor...
$image->newImage( $width, $height, new ImagickPixel( 'lightgray' ) );
$draw = new ImagickDraw(); //Create a new drawing class (?)
$draw->setFillColor('wheat'); // Set up some colors to use for fill and outline
$draw->setStrokeColor( new ImagickPixel( 'green' ) );
$draw->circle( $width/2, $height/2, $width/2, $width/2 ); // Draw the circle already
$image->drawImage( $draw ); // Apply the stuff from the draw class to the image canvas
$image->setImageFormat('jpg'); // Give the image a format
header('Content-type: image/jpeg'); // Prepare the web browser to display an image
echo $image; // Publish it to the world!
//$image->writeImage('someimage.jpg"); // ...Or just write it to a file...
?>