Magick::Drawable

Drawable provides a convenient interface for preparing vector, image, or text arguments for the Image::draw() method. Each instance of a Drawable sub-class represents a single drawable object.

The following is an example of how sub-classes of Drawable may be used:

#include <Magick++.h>

using namespace std;
using namespace Magick;

int main(int argc,char **argv)
{
    // Create base image (white image of 600 by 400 pixels)
    Image image( Geometry(600,400), Color("white") );

    // Set draw options
    image.penColor("red");
    image.lineWidth(5) ;

    // Draw a circle
    image.draw( DrawableCircle(100,100, 150,150) );

    // Draw a rectangle
    image.draw( DrawableRectangle(200,200 300,300) );

    // Display the result
    image.display( );
}

Since Drawable is an object it may be saved in an array or a list for later (perhaps repeated) use. Drawable depends on the simple Coordinate structure (based on STL pair)which represents a pair of x,y coodinates.  The methods provided by the Coordinate structure are shown in the following table:
 
Coordinate Structure Methods
Method/Member
Signature
Description
Coordinate
void Default Constructor
double x_, double y_ Constructor, setting first & second
first
double x_ x coordinate member
second
double y_ y coordinate member

The Drawable classes are shown in the following table:
 
Drawable Classes
Sub-Class
Constructor Signature
Description
DrawableArc
double startX_, double startY_, double endX_, double endY_, double startDegrees, double endDegrees_ Draw an arc using the stroke color and based on the circle starting at coordinates startX_,startY_, and ending with coordinates endX_,endY_, and bounded by the rotational arc startDegrees_,endDegrees_
DrawableBezier
const std::list<Magick::Coordinate> &coordinates_ Draw a bezier curve using the stroke color and based on the coordinates specified by the coordinates_ list.
DrawableCircle
double originX_, double originY_, double perimX_, double perimY_ Draw a circle using the stroke color and thickness using specified origin and perimeter coordinates. If a fill color is specified, then the object is filled.
DrawableColor
double x_, double y_, PaintMethod paintMethod_ Color image according to paintMethod. The point method recolors the target pixel.  The replace method recolors any pixel that matches the color of the target pixel.  Floodfill recolors any pixel that matches the color of the target pixel and is a neighbor,  whereas filltoborder recolors any neighbor pixel that is not the border color. Finally, reset recolors all pixels.
DrawableEllipse
double originX_, double originY_, double width_, double height_, double arcStart_, double arcEnd_ Draw an ellipse using the stroke color and thickness, specified origin, width & height, as well as specified start and end of arc in degrees. If a fill color is specified, then the object is filled.
DrawableImage
double x_, double y_, const string &image_ Composite image (file) with image file at specified coordinates.
 DrawableLine
double startX_, double startY_, double endX_, double endY_ Draw a line using stroke color and thickness using starting and ending coordinates
DrawableMatte
double x_, double y_, PaintMethod paintMethod_ Change the pixel matte value to transparent. The point method changes the matte value of the target pixel.  The replace method changes the matte value of any pixel that matches the color of the target pixel. Floodfill changes the matte value of any pixel that matches the color of the target pixel and is a neighbor, whereas filltoborder changes the matte value of any neighbor pixel that is not the border color, Finally reset changes the matte value of all pixels.
DrawablePath
     
DrawablePoint
double x_, double y_ Draw a point using stroke color and thickness at coordinate
DrawablePolygon
const std::list<Magick::Coordinate> &coordinates_ Draw an arbitrary polygon using stroke color and thickness consisting of three or more coordinates contained in an STL list. If a fill color is specified, then the object is filled.
DrawablePolyline
const std::list<Magick::Coordinate> &coordinates_ Draw an arbitrary polyline using stroke color and thickness consisting of three or more coordinates contained in an STL list. If a fill color is specified, then the object is filled.
DrawableRectangle
double upperLeftX_, double upperLeftY_, double lowerRightX_, double lowerRightY Draw a rectangle using stroke color and thickness from upper-left coordinates to lower-right coordinates.  If a fill color is specified, then the object is filled.
DrawableRoundRectangle
double centerX_, double centerY_, double width_, double hight_, double cornerWidth_, double cornerHeight_ Draw a rounded rectangle using stroke color and thickness, with specified center coordinate, specified width and height, and specified corner width and height.  If a fill color is specified, then the object is filled.
DrawableText
double x_, double y_, std::string text_ Annotate image with text using stroke color, font, font pointsize, and box color (text background color), at specified coordinates. If text contains special format characters the image filename, type, width, height, or other image attributes may be incorporated in the text (see label()).