DrawingContext

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

class DrawingContext {}

Members

Aliases

boxColor
alias boxColor = textUnderColor

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

fillColor
alias fillColor = fill

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

fillPattern
alias fillPattern = fill

Pattern to use when filling drawn objects.

strokeColor
alias strokeColor = stroke

Color to use when drawing object outlines.

strokePattern
alias strokePattern = stroke

Pattern to use when filling drawn objects.

Functions

affine
void affine(AffineMatrix matrix)

Transforms the coordinate system by a 3x3 transformation matrix.

antialias
void antialias(bool antialias)

Specify if the text and stroke should be antialiased.

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

Draws an arc within a rectangle.

bezier
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.

borderColor
void borderColor(const(Color) color)

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

circle
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.

clipPath
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.

clipRule
void clipRule(FillRule rule)

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

clipUnits
void clipUnits(ClipPathUnits units)

Defines the coordinate space within the clipping region.

color
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.

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

Composite filename/image with the receiver image.

decorate
void decorate(DecorationType decoration)

Specify text decoration.

draw
void draw(Image image)

Apply the drawing context to the image.

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

Draw an ellipse.

encoding
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.).

fill
void fill(const(Color) fillColor)

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

fill
void fill(size_t x, size_t y, size_t width, size_t height, void delegate(DrawingContext path) pattern)

Pattern to use when filling drawn objects.

fill
void fill(Gradient gradient)

The gradient to use when filling drawn objects.

fillOpacity
void fillOpacity(double opacity)

Specify the fill opacity.

fillRule
void fillRule(FillRule rule)

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

font
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.

fontFamily
void fontFamily(string family)

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

fontSize
void fontSize(double pointSize)

Text rendering font point size

fontStretch
void fontStretch(StretchType type)

Specify the spacing between text characters.

fontStyle
void fontStyle(StyleType type)

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

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

Specify the font weight.

gravity
void gravity(GravityType type)

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

interlineSpacing
void interlineSpacing(double spacing)

Modify the spacing between lines when text has multiple lines.

interwordSpacing
void interwordSpacing(double spacing)

Modify the spacing between words in text.

kerning
void kerning(double kerning)

Modify the spacing between letters in text.

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

Draw a line from start to end.

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

Make the image transparent according to the specified PaintMethod constant.

opacity
void opacity(double opacity)

Specify the fill and stroke opacities.

path
void path(string svgPath)

Draw using SVG-compatible path drawing commands.

point
void point(size_t x, size_t y)

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

polygon
void polygon(size_t[] points)

Draw a polygon.

polyline
void polyline(size_t[] points)

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

pop
void pop()

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

push
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.

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

Draw a rectangle.

rotate
void rotate(double angle)

Specify a rotation transformation to the coordinate space.

roundRectangle
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.

scale
void scale(double xScale, double yScale)

Define a scale transformation to the coordinate space.

skewX
void skewX(double angle)

Define a skew transformation along the x-axis.

skewY
void skewY(double angle)

Define a skew transformation along the y-axis.

stroke
void stroke(const(Color) strokeColor)

Color to use when drawing object outlines.

stroke
void stroke(size_t x, size_t y, size_t width, size_t height, void delegate(DrawingContext path) pattern)

Pattern to use when filling drawn objects.

stroke
void stroke(Gradient gradient)

The gradient to use when filling drawn objects.

strokeAntialias
void strokeAntialias(bool antialias)

Specify if the stroke should be antialiased.

strokeDashArray
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.

strokeDashOffset
void strokeDashOffset(double offset)

Specify the initial distance into the dash pattern.

strokeLineCap
void strokeLineCap(LineCap cap)

Specify how the line ends should be drawn.

strokeLineJoin
void strokeLineJoin(LineJoin join)

Specify how corners are drawn.

strokeMiterLimit
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.

strokeOpacity
void strokeOpacity(double opacity)

Specify the stroke opacity.

strokeWidth
void strokeWidth(double width)

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

text
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.

textAlign
void textAlign(AlignType type)

Align text relative to the starting point.

textAntialias
void textAntialias(bool antialias)

Specify if the text should be antialiased.

textUnderColor
void textUnderColor(Color color)

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

translate
void translate(size_t x, size_t y)

Specify a translation operation on the coordinate space.

Variables

operations
string operations;
Undocumented in source.

Meta