The OpenD Programming Language

IRenderingContext2D

Describes the printed 2D renderer.

This is the law, specific implementation MUST obey this interface and not the underlying implementation in PDF/SVG/whatever (and if necessary revise this spec).

We are heavily influenced by the HTML5 Canvas 2D context API, for its familiarity.

Members

Functions

beginPath
void beginPath(float x, float y)

The context always has a current default path. There is only one current path, it is not part of the drawing state. Resets the current path, and move the cursor to (x, y).

closePath
void closePath()

Close the path, returning to the initial first point. TODO: specify exactly what it does.

drawImage
void drawImage(Image image, float x, float y)

Draws an image at the given position.

drawImage
void drawImage(Image image, float x, float y, float width, float height)

Draws an image at the given position, with the given width and height. Both width and height must be provided.

fill
void fill()

Fills the subpaths of the current path or the given path with the current fill style. Uses the last set fill style, line width for the whole path.

fillAndStroke
void fillAndStroke()

Both fills and strokes the subpaths of the current path, in a more efficient way than calling fill and stroke separately. Uses the last set fill style, line width for the whole path.

fillRect
void fillRect(float x, float y, float width, float height)
fillStyle
void fillStyle(Brush brush)
void fillStyle(const(char)[] color)

Changes the current fill brush (Default = "black").

fillText
void fillText(const(char)[] text, float x, float y)

Draw filled text.

fontFace
void fontFace(string fontFace)

Changes font face (default = Helvetica)

fontSize
void fontSize(float sizeInPt)

Changes font size in points (default = 11pt) Warning: not millimeters.

fontStyle
void fontStyle(FontStyle fontStyle)

Changes font style (default = FontStyle.normal)

fontWeight
void fontWeight(FontWeight fontWeight)

Changes font weight (Default = FontWeight.normal)

getLineDash
float[] getLineDash()

Returns a copy of the current line dash pattern. The array returned will always have an even number of entries (i.e. the pattern is normalized).

lineDashOffset
void lineDashOffset(float offset)
float lineDashOffset()

Returns the phase offset (in the same units as the line dash pattern). Can be set, to change the phase offset. Values that are not finite values are ignored.

lineTo
void lineTo(float dx, float dy)

Add a subpath forming a line. Its exact width is set when the path is drawn with fill, stroke or fillAndStroke.

lineWidth
void lineWidth(float width)

Change the width of a line. The whole path has the same line width.

measureText
TextMetrics measureText(const(char)[] text)

Returns a TextMetrics struct that contains information about the measured text (such as its width, for example).

newPage
void newPage()

Start a new page, finish the previous one. This invalidates any transformation. The origin (0, 0) becomes again the top-left point of each page.

pageHeight
float pageHeight()

Number of units in a page. Return: Page height in millimeters.

pageWidth
float pageWidth()

Number of units in a page. Return: Page width in millimeters.

restore
void restore()

Pop state stack and restore state

rotate
void rotate(float angle)

Changes the transformation matrix to apply a rotation transformation with the given characteristics. The angle is in radians, the direction is clockwise.

save
void save()

Push state on state stack. What this states contains: - transformation matrices

scale
void scale(float x, float y)

Changes the transformation matrix to apply a scaling transformation with the given characteristics.

setLineDash
void setLineDash(float[] segments)

Sets the current line dash pattern (as used when stroking). The argument is an array of distances for which to alternately have the line on and the line off.

stroke
void stroke()

Strokes the subpaths of the current path or the given path with the current stroke style. Uses the last set fill style, line width for the whole path.

strokeStyle
void strokeStyle(Brush brush)
void strokeStyle(const(char)[] color)

Changes the current stroke brush (Default = "black").

textAlign
void textAlign(TextAlign alignment)

Changes text alignment (default = TextAlign.start)

textBaseline
void textBaseline(TextBaseline baseline)

Changes text baseline (default = TextBaseline.alphabetic)

translate
void translate(float dx, float dy)

Changes the transformation matrix to apply a translation transformation with the given characteristics.

See Also

Meta