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:
This class is derived, and can use functions, from:
wxWidgets docs: wxGraphicsContext
Summary
Functions
Sets the clipping region to the intersection of the given region and the previously set clipping region.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Concatenates the passed in transform with the current transform of this context.
Create a lightweight context that can be used only for measuring text.
Creates a wxGraphicsContext from a wxWindowDC.
Creates a native brush from a wxBrush.
Creates a native graphics font from a wxFont and a text colour.
Creates a font object with the specified attributes.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
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
Creates a native affine transformation matrix from the passed in values.
Creates a native graphics path which is initially empty.
Creates a native pen from a wxPen.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
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
Destroys the object
Draws the bitmap.
Draws an ellipse.
Draws the icon.
Draws a polygon.
Draws the path by first filling and then stroking.
Draws a rectangle.
Draws a rounded rectangle.
Draws text at the defined position.
Draws text at the defined position.
Draws text at the defined position.
Fills the path with the current brush.
Fills the widths array with the widths from the beginning of text to the
corresponding character of text.
Gets the dimensions of the string using the currently selected font.
Gets the current transformation matrix of this context.
Resets the clipping to original shape.
Rotates the current transformation matrix (in radians).
Scales the current transformation matrix.
Sets the brush for filling paths.
Sets the font for drawing text.
Sets the font for drawing text.
Sets the pen used for stroking.
Sets the current transformation matrix of this context.
Strokes a single line.
Stroke lines connecting all the points.
Strokes along a path with the current pen.
Translates the current transformation matrix.
Types
-type wxGraphicsContext() :: wx:wx_object().
Functions
clip(This :: wxGraphicsContext(), Region :: wxRegion:wxRegion()) -> 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:
Clipping region should be given in logical coordinates.
Calling this function can only make the clipping region smaller, never larger.
You need to call
resetClip/1first if you want to set the clipping region exactly to the region specified.If resulting clipping region is empty, then all drawing upon the context is clipped out (all changes made by drawing operations are masked out).
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Concatenates the passed in transform with the current transform of this context.
create() -> wxGraphicsContext()
Create a lightweight context that can be used only for measuring text.
create(WindowDC) -> wxGraphicsContext()
Types
WindowDC = wxWindowDC:wxWindowDC() | wxWindow:wxWindow() | wxMemoryDC:wxMemoryDC() | wxImage:wxImage()
Creates a wxGraphicsContext from a wxWindowDC.
Types
This = wxGraphicsContext()
Brush = wxBrush:wxBrush()
Result = wxGraphicsBrush:wxGraphicsBrush()
Creates a native brush from a wxBrush.
-spec createFont(This, Font) -> wxGraphicsFont:wxGraphicsFont() when This :: wxGraphicsContext(), Font :: wxFont:wxFont().
-spec createFont(This, SizeInPixels, Facename) -> wxGraphicsFont:wxGraphicsFont() when This :: wxGraphicsContext(), SizeInPixels :: number(), Facename :: unicode:chardata(); (This, Font, [Option]) -> wxGraphicsFont:wxGraphicsFont() when This :: wxGraphicsContext(), Font :: wxFont:wxFont(), Option :: {col, wx:wx_colour()}.
Creates a native graphics font from a wxFont and a text colour.
Remark: For Direct2D graphics fonts can be created from TrueType fonts only.
-spec createFont(This, SizeInPixels, Facename, [Option]) -> wxGraphicsFont:wxGraphicsFont() when This :: wxGraphicsContext(), SizeInPixels :: number(), Facename :: unicode:chardata(), Option :: {flags, integer()} | {col, wx:wx_colour()}.
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
Types
This = wxGraphicsContext()
X1 = Y1 = X2 = Y2 = number()
Stops = wxGraphicsGradientStops:wxGraphicsGradientStops()
Result = wxGraphicsBrush:wxGraphicsBrush()
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Types
This = wxGraphicsContext()
X1 = Y1 = X2 = Y2 = number()
C1 = C2 = wx:wx_colour()
Result = 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
-spec createMatrix(This) -> wxGraphicsMatrix:wxGraphicsMatrix() when This :: wxGraphicsContext().
-spec createMatrix(This, [Option]) -> wxGraphicsMatrix:wxGraphicsMatrix() when This :: wxGraphicsContext(), Option :: {a, number()} | {b, number()} | {c, number()} | {d, number()} | {tx, number()} | {ty, number()}.
Creates a native affine transformation matrix from the passed in values.
The default parameters result in an identity matrix.
createPath(This :: wxGraphicsContext()) -> Result
Types
Result = wxGraphicsPath:wxGraphicsPath()
Creates a native graphics path which is initially empty.
Creates a native pen from a wxPen.
Prefer to use the overload taking wxGraphicsPenInfo (not implemented in wx) unless you
already have a wxPen as constructing one only to pass it to this method is wasteful.
Types
This = wxGraphicsContext()
StartX = StartY = EndX = EndY = Radius = number()
Stops = wxGraphicsGradientStops:wxGraphicsGradientStops()
Result = wxGraphicsBrush:wxGraphicsBrush()
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Types
This = wxGraphicsContext()
StartX = StartY = EndX = EndY = Radius = number()
OColor = CColor = wx:wx_colour()
Result = wxGraphicsBrush:wxGraphicsBrush()
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
destroy(This :: wxGraphicsContext()) -> ok
Destroys the object
Draws the bitmap.
In case of a mono bitmap, this is treated as a mask and the current brushed is used for filling.
Draws an ellipse.
Draws the icon.
-spec drawLines(This, Points) -> ok when This :: wxGraphicsContext(), Points :: [{X :: float(), Y :: float()}].
-spec drawLines(This, Points, [Option]) -> ok when This :: wxGraphicsContext(), Points :: [{X :: float(), Y :: float()}], Option :: {fillStyle, wx:wx_enum()}.
Draws a polygon.
-spec drawPath(This, Path) -> ok when This :: wxGraphicsContext(), Path :: wxGraphicsPath:wxGraphicsPath().
-spec drawPath(This, Path, [Option]) -> ok when This :: wxGraphicsContext(), Path :: wxGraphicsPath:wxGraphicsPath(), Option :: {fillStyle, wx:wx_enum()}.
Draws the path by first filling and then stroking.
Draws a rectangle.
Draws a rounded rectangle.
Draws text at the defined position.
-spec drawText(This, Str, X, Y, Angle) -> ok when This :: wxGraphicsContext(), Str :: unicode:chardata(), X :: number(), Y :: number(), Angle :: number(); (This, Str, X, Y, BackgroundBrush) -> ok when This :: wxGraphicsContext(), Str :: unicode:chardata(), X :: number(), Y :: number(), BackgroundBrush :: wxGraphicsBrush:wxGraphicsBrush().
Draws text at the defined position.
Types
This = wxGraphicsContext()
Str = unicode:chardata()
X = Y = Angle = number()
BackgroundBrush = wxGraphicsBrush:wxGraphicsBrush()
Draws text at the defined position.
-spec fillPath(This, Path) -> ok when This :: wxGraphicsContext(), Path :: wxGraphicsPath:wxGraphicsPath().
-spec fillPath(This, Path, [Option]) -> ok when This :: wxGraphicsContext(), Path :: wxGraphicsPath:wxGraphicsPath(), Option :: {fillStyle, wx:wx_enum()}.
Fills the path with the current brush.
getPartialTextExtents(This, Text) -> [number()]
Fills the widths array with the widths from the beginning of text to the
corresponding character of text.
getTextExtent(This :: wxGraphicsContext(), Text :: unicode:chardata()) -> Result
Types
Result = {Width :: number(), Height :: number(), Descent :: number(), ExternalLeading :: number()}
Gets the dimensions of the string using the currently selected font.
getTransform(This :: wxGraphicsContext()) -> Result
Types
Result = wxGraphicsMatrix:wxGraphicsMatrix()
Gets the current transformation matrix of this context.
resetClip(This :: wxGraphicsContext()) -> ok
Resets the clipping to original shape.
rotate(This :: wxGraphicsContext(), Angle :: number()) -> ok
Rotates the current transformation matrix (in radians).
scale(This :: wxGraphicsContext(), XScale :: number(), YScale :: number()) -> ok
Types
XScale = YScale = number()
Scales the current transformation matrix.
Sets the brush for filling paths.
Sets the font for drawing text.
Sets the font for drawing text.
Remark: For Direct2D only TrueType fonts can be used.
Sets the pen used for stroking.
Sets the current transformation matrix of this context.
Strokes a single line.
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.
Strokes along a path with the current pen.
translate(This :: wxGraphicsContext(), Dx :: number(), Dy :: number()) -> ok
Types
Dx = Dy = number()
Translates the current transformation matrix.