Last update Sun May 11 01:02:34 2014

dmagick.DrawingContext

License:
zlib (See accompanying LICENSE file)

Authors:
Mike Wey

alias AlignType = dmagick.c.draw.AlignType;

See Also:
dmagick.c.draw.AlignType

alias ClipPathUnits = dmagick.c.draw.ClipPathUnits;

See Also:
dmagick.c.draw.ClipPathUnits

alias DecorationType = dmagick.c.draw.DecorationType;

See Also:
dmagick.c.draw.DecorationType

alias FillRule = dmagick.c.draw.FillRule;

See Also:
dmagick.c.draw.FillRule

alias LineCap = dmagick.c.draw.LineCap;

See Also:
dmagick.c.draw.LineCap

alias LineJoin = dmagick.c.draw.LineJoin;

See Also:
dmagick.c.draw.LineJoin

alias PaintMethod = dmagick.c.draw.PaintMethod;

See Also:
dmagick.c.draw.PaintMethod

alias StretchType = dmagick.c.type.StretchType;

See Also:
dmagick.c.type.StretchType

alias StyleType = dmagick.c.type.StyleType;

See Also:
dmagick.c.type.StyleType

class DrawingContext;

Drawable provides a convenient interface for preparing vector, image, or text arguments.

void draw(Image image);

Apply the drawing context to the image.

void affine(AffineMatrix matrix);

Transforms the coordinate system by a 3x3 transformation matrix.

void antialias(bool antialias);

Specify if the text and stroke should be antialiased.

void arc(size_t startX, size_t startY, size_t endX, size_t endY, double startDegrees, double endDegrees);

Draws an arc within a rectangle.

void bezier(size_t x1, size_t y1, size_t cx1, size_t cy1, size_t cx2, size_t cy2, size_t x2, size_t y2, size_t[] points...);

Draw a cubic Bezier curve.

The arguments are pairs of points. At least 4 pairs must be specified. Each point xn, yn on the curve is associated with a control point cxn, cyn. The first point, x1, y1, is the starting point. The last point, xn, yn, is the ending point. Other point/control point pairs specify intermediate points on a polybezier curve.

void borderColor(const(Color) color);

Set the image border color. The default is "#dfdfdf".

void clipPath(void delegate(DrawingContext path) defineClipPath);

Defines a clip-path. Within the delegate, call other drawing primitive methods (rectangle, polygon, text, etc.) to define the clip-path. The union of all the primitives (excluding the effects of rendering methods such as stroke_width, etc.) is the clip-path.

Parameters:

path The delegate that defines the clip-path using using the provided DrawingContext.

void clipRule(FillRule rule);

Specify how to determine if a point on the image is inside clipping region.

See Also:
the 'fill-rule' property in the Scalable Vector Graphics (SVG) 1.1 Specification.

void clipUnits(ClipPathUnits units);

Defines the coordinate space within the clipping region.

See Also:
Establishing a New Clipping Path in the Scalable Vector Graphics (SVG) 1.1 Specification.

void circle(size_t xOrigin, size_t yOrigin, size_t xPerimeter, size_t yPerimeter);
void circle(size_t xOrigin, size_t yOrigin, size_t radius);

Draw a circle.

Parameters:

size_t xOrigin The x coordinate for the center of the circle.
size_t yOrigin The y coordinate for the center of the circle.
size_t xPerimeter The x coordinate for a point on the perimeter of the circle.
size_t yPerimeter The x coordinate for a point on the perimeter of the circle.

void color(size_t x, size_t y, PaintMethod method);

Set color in image according to the specified PaintMethod constant. If you use the PaintMethod.FillToBorderMethod, assign the border color with the DrawingContext.borderColor property.

void composite(ssize_t xOffset, ssize_t yOffset, size_t width, size_t height, string filename, CompositeOperator compositeOp = CompositeOperator.OverCompositeOp);
void composite(ssize_t xOffset, ssize_t yOffset, size_t width, size_t height, Image image, CompositeOperator compositeOp = CompositeOperator.OverCompositeOp);

Composite filename/image with the receiver image.

Parameters:

ssize_t xOffset The x-offset of the composited image, measured from the upper-left corner of the image.
ssize_t yOffset The y-offset of the composited image, measured from the upper-left corner of the image.
size_t width Scale the composite image to this size. If value is 0, the composite image is not scaled.
size_t height Scale the composite image to this size. If value is 0, the composite image is not scaled.
string filename Filename of the mage to use in the composite operation.
image Image to use in the composite operation.
CompositeOperator compositeOp The composite operation to use.

void decorate(DecorationType decoration);

Specify text decoration.

void ellipse(size_t xOrigin, size_t yOrigin, size_t width, size_t height, double startDegrees, double endDegrees);

Draw an ellipse.

Parameters:

size_t xOrigin The x coordinate of the ellipse.
size_t yOrigin The y coordinate of the ellipse.
size_t width The horizontal radii.
size_t height The vertical radii.
double startDegrees Where to start the ellipse. 0 degrees is at 3 o'clock.
double endDegrees Whare to end the ellipse.

void encoding(FontEncoding encoding);

Specify the font encoding.

Note:

This specifies the character repertory (i.e., charset), and not the text encoding method (e.g., UTF-8, UTF-16, etc.).

void fill(const(Color) fillColor);
alias fillColor = fill;

Color to use when filling drawn objects. The default is "black".

void fill(size_t x, size_t y, size_t width, size_t height, void delegate(DrawingContext path) pattern);
alias fillPattern = fill;

Pattern to use when filling drawn objects.

Within the delegate, call other drawing primitive methods (rectangle, polygon, text, etc.) to define the pattern.

void fill(Gradient gradient);

The gradient to use when filling drawn objects.

void fillOpacity(double opacity);

Specify the fill opacity.

Parameters:

double opacity A number between 0 and 1.

void fillRule(FillRule rule);

Specify how to determine if a point on the image is inside a shape.

See Also:
the 'fill-rule' property in the Scalable Vector Graphics (SVG) 1.1 Specification.

void font(string font);

The font name or filename. You can tag a font to specify whether it is a Postscript, Truetype, or OPTION1 font. For example, Arial.ttf is a Truetype font, ps:helvetica is Postscript, and x:fixed is OPTION1.

The font name can be a complete filename such as "/mnt/windows/windows/fonts/Arial.ttf". The font name can also be a fully qualified X font name such as "-urw-times-medium-i-normal--0-0-0-0-p-0-iso8859-13".

void fontFamily(string family);

Specify the font family, such as "arial" or "helvetica".

void fontSize(double pointSize);

Text rendering font point size

void fontStretch(StretchType type);

Specify the spacing between text characters.

void fontStyle(StyleType type);

Specify the font style, i.e. italic, oblique, or normal.

void fontWeight(size_t weight);
void fontWeight(FontWeight weight);

Specify the font weight.

Eighter use the FontWeight enum or specify a number between 100 and 900.

void gravity(GravityType type);

Specify how the text is positioned. The default is NorthWestGravity.

void interlineSpacing(double spacing);

Modify the spacing between lines when text has multiple lines.

If positive, inserts additional space between lines. If negative, removes space between lines. The amount of space inserted or removed depends on the font.

void interwordSpacing(double spacing);

Modify the spacing between words in text.

If positive, inserts additional space between words. If negative, removes space between words. The amount of space inserted or removed depends on the font.

void kerning(double kerning);

Modify the spacing between letters in text.

If positive, inserts additional space between letters. If negative, removes space between letters. The amount of space inserted or removed depends on the font but is usually measured in pixels. That is, the following call adds about 5 pixels between each letter.

void line(size_t xStart, size_t yStart, size_t xEnd, size_t yEnd);

Draw a line from start to end.

void matte(size_t x, size_t y, PaintMethod method);

Make the image transparent according to the specified PaintMethod constant.

If you use the PaintMethod.FillToBorderMethod, assign the border color with the DrawingContext.borderColor property.

void opacity(double opacity);

Specify the fill and stroke opacities.

Parameters:

double opacity A number between 0 and 1.

void path(string svgPath);

Draw using SVG-compatible path drawing commands.

See Also:
" Paths" in the Scalable Vector Graphics (SVG) 1.1 Specification.

void point(size_t x, size_t y);

Set the pixel at x,y to the fill color.

void polygon(size_t[] points...);

Draw a polygon.

The arguments are a sequence of 2 or more points. If the last point is not the same as the first, the polygon is closed by drawing a line from the last point to the first.

void polyline(size_t[] points...);

Draw a polyline. Unlike a polygon, a polyline is not automatically closed.

void pop();

Restore the graphics context to the state it was in when push was called last.

void push();

Save the current state of the graphics context, including the attribute settings and the current set of primitives. Use the pop primitive to restore the state.

void rectangle(size_t xStart, size_t yStart, size_t xEnd, size_t yEnd);

Draw a rectangle.

void rotate(double angle);

Specify a rotation transformation to the coordinate space.

void roundRectangle(size_t xStart, size_t yStart, size_t xEnd, size_t yEnd, size_t cornerWidth, size_t cornerHeight);

Draw a rectangle with rounded corners.

Parameters:

size_t xStart The x coordinate for the upper left hand corner of the rectangle.
size_t yStart The y coordinate for the upper left hand corner of the rectangle.
size_t xEnd The x coordinate for the lower left hand corner of the rectangle.
size_t yEnd The y coordinate for the lower left hand corner of the rectangle.
size_t cornerWidth The width of the corner.
size_t cornerHeight The height of the corner.

void scale(double xScale, double yScale);

Define a scale transformation to the coordinate space.

void skewX(double angle);

Define a skew transformation along the x-axis.

Parameters:

double angle The amount of skew, in degrees.

void skewY(double angle);

Define a skew transformation along the y-axis.

Parameters:

double angle The amount of skew, in degrees.

void stroke(const(Color) strokeColor);
alias strokeColor = stroke;

Color to use when drawing object outlines.

void stroke(size_t x, size_t y, size_t width, size_t height, void delegate(DrawingContext path) pattern);
alias strokePattern = stroke;

Pattern to use when filling drawn objects.

Within the delegate, call other drawing primitive methods (rectangle, polygon, text, etc.) to define the pattern.

void stroke(Gradient gradient);

The gradient to use when filling drawn objects.

void strokeAntialias(bool antialias);

Specify if the stroke should be antialiased.

void strokeDashArray(const(double)[] dashArray...);

Describe a pattern of dashes to be used when stroking paths. The arguments are a list of pixel widths of alternating dashes and gaps.

The first argument is the width of the first dash. The second is the width of the gap following the first dash. The third argument is another dash width, followed by another gap width, etc.

void strokeDashOffset(double offset);

Specify the initial distance into the dash pattern.

void strokeLineCap(LineCap cap);

Specify how the line ends should be drawn.

void strokeLineJoin(LineJoin join);

Specify how corners are drawn.

void strokeMiterLimit(size_t limit);

Specify a constraint on the length of the "miter" formed by two lines meeting at an angle. If the angle if very sharp, the miter could be very long relative to the line thickness. The miter limit is a limit on the ratio of the miter length to the line width. The default is 4.

void strokeOpacity(double opacity);

Specify the stroke opacity.

Parameters:

double opacity A number between 0 and 1.

void strokeWidth(double width);

Specify the stroke width in pixels. The default is 1.

void text(size_t x, size_t y, string text);

Draw text at the location specified by (x,y). Use gravity to position text relative to (x, y). Specify the font appearance with the font, fontFamily, fontStretch, fontStyle, and fontWeight properties. Specify the text attributes with the textAlign, textAnchor, textAntialias, and textUndercolor properties.

To include a '%' in the text, use '%%'.

See Also:
Image.annotate for the image properties you can include in the string.

void textAlign(AlignType type);

Align text relative to the starting point.

void textAntialias(bool antialias);

Specify if the text should be antialiased.

void textUnderColor(Color color);
alias boxColor = textUnderColor;

If set, causes the text to be drawn over a box of the specified color.

void translate(size_t x, size_t y);

Specify a translation operation on the coordinate space.

struct Gradient;

This defines a Gradient used when drawing.

One thing to remember it that the gradient is always drawn from the top left corner of the image. And is repeated if it's smaller then the image height or width. This mean that the gradient you see in the object you are filling does not determine the stating point of the gradient but is filled the part of the gradient that would be there when starting at the top left corner of the image.

this(Color startColor, Color endColor, size_t size, GradientDirection direction = GradientDirection.Vertical);

Define a linear gradient.

Parameters:

Color startColor The starting Color.
Color endColor The end Color.
size_t size The height or with of the gradient.
Direction Determines is the gradient fades from top to bottom or from left to right.

enum FontEncoding: int;

This enumeration lists specific character repertories (i.e., charsets), and not text encoding methods (e.g., UTF-8, UTF-16, etc.).

AdobeCustom
AdobeExpert
AdobeStandard
AppleRoman
BIG5
GB2312
Johab
Latin1
Latin2
None
SJIScode
Symbol
Unicode
Wansung


enum FontWeight: int;

The font weight can be specified as one of 100, 200, 300, 400, 500, 600, 700, 800, or 900, or one of the following constants.

Any

No weight specified.

Normal

Normal weight, equivalent to 400.

Bold

Bold. equivalent to 700.

Bolder

Increases weight by 100.

Lighter

Decreases weight by 100.

enum GradientDirection: int;

GradientDirection determines if the gradient fades from top to bottom or from left to right.

Horizontal

Top to bottom.

Vertical

Left to right.