wxGraphicsContext
Description
A wxGraphicsContext instance is the object that is drawn upon. It is created by a renderer using wxGraphicsRenderer:createContext/2. This can be either directly using a renderer instance, or indirectly using the static convenience create/1 functions of wxGraphicsContext that always delegate the task to the default renderer.
Remark: For some renderers (like Direct2D or Cairo) processing of drawing operations may be deferred (Direct2D render target normally builds up a batch of rendering commands but defers processing of these commands, Cairo operates on a separate surface) so to make drawing results visible you need to update the content of the context by calling wxGraphicsContext::Flush() (not implemented in wx) or by destroying the context.
See: wxGraphicsRenderer:createContext/2, wxGCDC, wxDC
This class is derived (and can use functions) from: wxGraphicsObject
wxWidgets docs: wxGraphicsContext
destroy(This :: wxGraphicsContext()) -> ok
Creates a wxGraphicsContext from a wxWindow.
create() -> wxGraphicsContext()
Create a lightweight context that can be used only for measuring text.
create(WindowDC) -> wxGraphicsContext()
Types
Creates a wxGraphicsContext from a wxWindowDC.
createPen(This, Pen) -> wxGraphicsPen:wxGraphicsPen()
createBrush(This, Brush) -> wxGraphicsBrush:wxGraphicsBrush()
Creates a native brush from a wxBrush.
createRadialGradientBrush(This, StartX, StartY, EndX, EndY,
Radius, Stops) ->
wxGraphicsBrush:wxGraphicsBrush()
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
createRadialGradientBrush(This, StartX, StartY, EndX, EndY,
Radius, OColor, CColor) ->
wxGraphicsBrush:wxGraphicsBrush()
Types
Creates a native brush with a radial gradient. The brush originates at (@a startX, @a startY) and ends on a circle around (@a endX, @a endY) with the given @a radius. The gradient may be specified either by its start and end colours @a oColor and @a cColor or by a full set of gradient @a stops. The version taking wxGraphicsGradientStops is new in wxWidgets 2.9.1.
The ability to apply a transformation matrix to the gradient was added in 3.1.3
createLinearGradientBrush(This, X1, Y1, X2, Y2, Stops) ->
wxGraphicsBrush:wxGraphicsBrush()
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
createLinearGradientBrush(This, X1, Y1, X2, Y2, C1, C2) ->
wxGraphicsBrush:wxGraphicsBrush()
Creates a native brush with a linear gradient. The brush starts at (@a x1, @a y1) and ends at (@a x2, @a y2). Either just the start and end gradient colours (@a c1 and @a c2) or full set of gradient @a stops can be specified. The version taking wxGraphicsGradientStops is new in wxWidgets 2.9.1.
The matrix parameter was added in wxWidgets 3.1.3
createFont(This, Font) -> wxGraphicsFont:wxGraphicsFont()
createFont(This, SizeInPixels, Facename) ->
wxGraphicsFont:wxGraphicsFont()
createFont(This, Font, Facename :: [Option]) ->
wxGraphicsFont:wxGraphicsFont()
Creates a native graphics font from a wxFont and a text colour.
Remark: For Direct2D graphics fonts can be created from TrueType fonts only.
createFont(This, SizeInPixels, Facename, Options :: [Option]) ->
wxGraphicsFont:wxGraphicsFont()
Types
Creates a font object with the specified attributes.
The use of overload taking wxFont is preferred, see wxGraphicsRenderer:createFont/4 for more details.
Remark: For Direct2D graphics fonts can be created from TrueType fonts only.
Since: 2.9.3
createMatrix(This) -> wxGraphicsMatrix:wxGraphicsMatrix()
Types
createMatrix(This, Options :: [Option]) ->
wxGraphicsMatrix:wxGraphicsMatrix()
Types
Creates a native affine transformation matrix from the passed in values.
The default parameters result in an identity matrix.
createPath(This) -> wxGraphicsPath:wxGraphicsPath()
Types
Creates a native graphics path which is initially empty.
clip(This, Region) -> ok
Sets the clipping region to the intersection of the given region and the previously set clipping region.
The clipping region is an area to which drawing is restricted.
Remark:
clip(This, X, Y, W, H) -> ok
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
resetClip(This) -> ok
Types
Resets the clipping to original shape.
drawBitmap(This, Bmp, X, Y, W, H) -> ok
Draws the bitmap.
In case of a mono bitmap, this is treated as a mask and the current brushed is used for filling.
drawEllipse(This, X, Y, W, H) -> ok
Draws an ellipse.
drawIcon(This, Icon, X, Y, W, H) -> ok
Draws the icon.
drawLines(This, Points) -> ok
drawLines(This, Points, Options :: [Option]) -> ok
Draws a polygon.
drawPath(This, Path) -> ok
drawPath(This, Path, Options :: [Option]) -> ok
Draws the path by first filling and then stroking.
drawRectangle(This, X, Y, W, H) -> ok
Draws a rectangle.
drawRoundedRectangle(This, X, Y, W, H, Radius) -> ok
Draws a rounded rectangle.
drawText(This, Str, X, Y) -> ok
Draws text at the defined position.
drawText(This, Str, X, Y, Angle) -> ok
drawText(This, Str, X, Y, BackgroundBrush) -> ok
Types
Draws text at the defined position.
drawText(This, Str, X, Y, Angle, BackgroundBrush) -> ok
Types
Draws text at the defined position.
fillPath(This, Path) -> ok
fillPath(This, Path, Options :: [Option]) -> ok
Fills the path with the current brush.
strokePath(This, Path) -> ok
Strokes along a path with the current pen.
getPartialTextExtents(This, Text) -> [number()]
Fills the widths array with the widths from the beginning of text to the corresponding character of text.
getTextExtent(This, Text) -> Result
Gets the dimensions of the string using the currently selected font.
rotate(This, Angle) -> ok
Rotates the current transformation matrix (in radians).
scale(This, XScale, YScale) -> ok
Scales the current transformation matrix.
translate(This, Dx, Dy) -> ok
Translates the current transformation matrix.
getTransform(This) -> wxGraphicsMatrix:wxGraphicsMatrix()
Types
Gets the current transformation matrix of this context.
setTransform(This, Matrix) -> ok
Sets the current transformation matrix of this context.
concatTransform(This, Matrix) -> ok
Concatenates the passed in transform with the current transform of this context.
setBrush(This, Brush) -> ok
Sets the brush for filling paths.
setFont(This, Font) -> ok
Sets the font for drawing text.
setFont(This, Font, Colour) -> ok
Sets the font for drawing text.
Remark: For Direct2D only TrueType fonts can be used.
setPen(This, Pen) -> ok
Sets the pen used for stroking.
strokeLine(This, X1, Y1, X2, Y2) -> ok
Strokes a single line.
strokeLines(This, Points) -> ok
Stroke lines connecting all the points.
Unlike the other overload of this function, this method draws a single polyline and not a number of disconnected lines.