wxGraphicsContext(3erl)
π wxGraphicsContext π
wxGraphicsContext(3erl) β Erlang module definition, bestie. This is the manual page for wxGraphicsContext, and it's coming at you in two parts. This is part 1, and we are not skipping a single flag, type, remark, or little weird detail. Periodt. π«Ά
β¨ NAME β¨
wxGraphicsContext - Functions for wxGraphicsContext class
π«Ά DESCRIPTION π«Ά
Okay so a wxGraphicsContext instance is literally the object that is drawn upon. It is created by a renderer using wxGraphicsRenderer:createContext/2. You can do that 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. Slay.
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, and 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. No cap, that's the whole vibe. π
See: wxGraphicsRenderer:createContext/2, wxGCDC, wxDC
This class is derived (and can use functions) from: wxGraphicsObject
wxWidgets docs: wxGraphicsContext
π§ DATA TYPES π§
wxGraphicsContext() = wx:wx_object()
π EXPORTS π
Here's every export in this part. We're keeping the order, the signatures, the types, the little remarks β all of it. π
π destroy
destroy(This :: wxGraphicsContext()) -> ok
Creates a wxGraphicsContext from a wxWindow.
See: wxGraphicsRenderer:createContext/2
π create
create() -> wxGraphicsContext()
create(WindowDC) -> wxGraphicsContext()
Create a lightweight context that can be used only for measuring text. β¨
Types for create(WindowDC):
WindowDC =
wxWindowDC:wxWindowDC() |
wxWindow:wxWindow() |
wxMemoryDC:wxMemoryDC() |
wxImage:wxImage()
Creates a wxGraphicsContext from a wxWindowDC.
See: wxGraphicsRenderer:createContext/2
π createPen
createPen(This, Pen) -> wxGraphicsPen:wxGraphicsPen()
Types:
This = wxGraphicsContext()
Pen = wxPen:wxPen()
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. Ngl, the page is telling you to be efficient. π
π createBrush
createBrush(This, Brush) -> wxGraphicsBrush:wxGraphicsBrush()
Types:
This = wxGraphicsContext()
Brush = wxBrush:wxBrush()
Creates a native brush from a wxBrush.
π createRadialGradientBrush
createRadialGradientBrush(This, StartX, StartY, EndX, EndY, Radius, Stops) ->
wxGraphicsBrush:wxGraphicsBrush()
createRadialGradientBrush(This, StartX, StartY, EndX, EndY, Radius, OColor, CColor) ->
wxGraphicsBrush:wxGraphicsBrush()
Types for the Stops version:
This = wxGraphicsContext()
StartX = StartY = EndX = EndY = Radius = number()
Stops = wxGraphicsGradientStops:wxGraphicsGradientStops()
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Types for the OColor, CColor version:
This = wxGraphicsContext()
StartX = StartY = EndX = EndY = Radius = number()
OColor = CColor = wx:wx_colour()
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
createLinearGradientBrush(This, X1, Y1, X2, Y2, Stops) ->
wxGraphicsBrush:wxGraphicsBrush()
createLinearGradientBrush(This, X1, Y1, X2, Y2, C1, C2) ->
wxGraphicsBrush:wxGraphicsBrush()
Types for the Stops version:
This = wxGraphicsContext()
X1 = Y1 = X2 = Y2 = number()
Stops = wxGraphicsGradientStops:wxGraphicsGradientStops()
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Types for the C1, C2 version:
This = wxGraphicsContext()
X1 = Y1 = X2 = Y2 = number()
C1 = C2 = wx:wx_colour()
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
First up:
createFont(This, Font) -> wxGraphicsFont:wxGraphicsFont()
Types:
This = wxGraphicsContext()
Font = wxFont:wxFont()
Then these two signatures:
createFont(This, SizeInPixels, Facename) -> wxGraphicsFont:wxGraphicsFont()
createFont(This, Font, Facename :: [Option]) -> wxGraphicsFont:wxGraphicsFont()
Types:
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.
Then the one with Options:
createFont(This, SizeInPixels, Facename, Options :: [Option]) -> wxGraphicsFont:wxGraphicsFont()
Types:
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
π createMatrix
createMatrix(This) -> wxGraphicsMatrix:wxGraphicsMatrix()
Types:
This = wxGraphicsContext()
createMatrix(This, Options :: [Option]) -> wxGraphicsMatrix:wxGraphicsMatrix()
Types:
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
createPath(This) -> wxGraphicsPath:wxGraphicsPath()
Types:
This = wxGraphicsContext()
Creates a native graphics path which is initially empty.
π clip
clip(This, Region) -> ok
Types:
This = wxGraphicsContext()
Region = wxRegion:wxRegion()
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
Types:
This = wxGraphicsContext()
X = Y = W = H = number()
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
π resetClip
resetClip(This) -> ok
Types:
This = wxGraphicsContext()
Resets the clipping to original shape.
π drawBitmap
drawBitmap(This, Bmp, X, Y, W, H) -> ok
Types:
This = wxGraphicsContext()
Bmp = wxBitmap:wxBitmap()
X = Y = W = H = number()
Draws the bitmap.
In case of a mono bitmap, this is treated as a mask and the current brushed is used for filling. Yes, brushed β the page said it, I'm not arguing with the page. π
π drawEllipse
drawEllipse(This, X, Y, W, H) -> ok
Types:
This = wxGraphicsContext()
X = Y = W = H = number()
Draws an ellipse.
π drawIcon
drawIcon(This, Icon, X, Y, W, H) -> ok
Types:
This = wxGraphicsContext()
Icon = wxIcon:wxIcon()
X = Y = W = H = number()
Draws the icon.
π drawLines
drawLines(This, Points) -> ok
Types:
This = wxGraphicsContext()
Points = [{X :: float(), Y :: float()}]
drawLines(This, Points, Options :: [Option]) -> ok
Types:
This = wxGraphicsContext()
Points = [{X :: float(), Y :: float()}]
Option = {fillStyle, wx:wx_enum()}
Draws a polygon.
π drawPath
drawPath(This, Path) -> ok
Types:
This = wxGraphicsContext()
Path = wxGraphicsPath:wxGraphicsPath()
drawPath(This, Path, Options :: [Option]) -> ok
Types:
This = wxGraphicsContext()
Path = wxGraphicsPath:wxGraphicsPath()
Option = {fillStyle, wx:wx_enum()}
Draws the path by first filling and then stroking.
π drawRectangle
drawRectangle(This, X, Y, W, H) -> ok
Types:
This = wxGraphicsContext()
X = Y = W = H = number()
Draws a rectangle.
π drawRoundedRectangle
drawRoundedRectangle(This, X, Y, W, H, Radius) -> ok
Types:
This = wxGraphicsContext()
X = Y = W = H = Radius = number()
Draws a rounded rectangle.
π drawText
drawText(This, Str, X, Y) -> ok
Types:
This = wxGraphicsContext()
Str = unicode:chardata()
X = Y = number()
Draws text at the defined position.
drawText(This, Str, X, Y, Angle) -> ok
drawText(This, Str, X, Y, BackgroundBrush) -> ok
Types:
This = wxGraphicsContext()
Str = unicode:chardata()
X = Y = number()
BackgroundBrush = wxGraphicsBrush:wxGraphicsBrush()
Draws text at the defined position.
drawText(This, Str, X, Y, Angle, BackgroundBrush) -> ok
Types:
This = wxGraphicsContext()
Str = unicode:chardata()
X = Y = Angle = number()
BackgroundBrush = wxGraphicsBrush:wxGraphicsBrush()
Draws text at the defined position.
π fillPath
fillPath(This, Path) -> ok
Types:
This = wxGraphicsContext()
Path = wxGraphicsPath:wxGraphicsPath()
fillPath(This, Path, Options :: [Option]) -> ok
Types:
This = wxGraphicsContext()
Path = wxGraphicsPath:wxGraphicsPath()
Option = {fillStyle, wx:wx_enum()}
Fills the path with the current brush.
strokePath(This, Path) -> ok
Types:
This=wxGraphicsContext()Path=wxGraphicsPath:wxGraphicsPath()
Strokes along a path using the current pen. Thatβs the whole vibe π
getPartialTextExtents(This, Text) -> [number()]
Types:
This=wxGraphicsContext()Text=unicode:chardata()
Fills the widths array with the widths from the beginning of text to the corresponding character of text. Basically it gives you the width up to each character, bestie β¨
getTextExtent(This, Text) -> Result
Types:
Result={Width :: number(), Height :: number(), Descent :: number(), ExternalLeading :: number()}This=wxGraphicsContext()Text=unicode:chardata()
Gets the dimensions of the string using the currently selected font. You get the whole little tuple package: width, height, descent, and external leading π
rotate(This, Angle) -> ok
Types:
This=wxGraphicsContext()Angle=number()
Rotates the current transformation matrix (in radians). Spin that matrix, icon behavior only πͺοΈ
scale(This, XScale, YScale) -> ok
Types:
This=wxGraphicsContext()XScale=YScale=number()
Scales the current transformation matrix. Stretch it, shrink it, make it make sense π¦
translate(This, Dx, Dy) -> ok
Types:
This=wxGraphicsContext()Dx=Dy=number()
Translates the current transformation matrix. Move it along, no cap π
getTransform(This) -> wxGraphicsMatrix:wxGraphicsMatrix()
Types:
This=wxGraphicsContext()
Gets the current transformation matrix of this context. It hands you a wxGraphicsMatrix:wxGraphicsMatrix() and youβre like okay periodt π
setTransform(This, Matrix) -> ok
Types:
This=wxGraphicsContext()Matrix=wxGraphicsMatrix:wxGraphicsMatrix()
Sets the current transformation matrix of this context. Swaps the whole transform vibe to the one you pass in π₯
concatTransform(This, Matrix) -> ok
Types:
This=wxGraphicsContext()Matrix=wxGraphicsMatrix:wxGraphicsMatrix()
Concatenates the passed-in transform with the current transform of this context. Itβs giving βstack the matrices, bestieβ π«Ά
setBrush(This, Brush) -> ok
Types:
This=wxGraphicsContext()Brush=wxGraphicsBrush:wxGraphicsBrush() | wxBrush:wxBrush()
Sets the brush for filling paths. Fill it up, make it cute πΈ
setFont(This, Font) -> ok
Types:
This=wxGraphicsContext()Font=wxGraphicsFont:wxGraphicsFont()
Sets the font for drawing text. Font game: strong π
setFont(This, Font, Colour) -> ok
Types:
This=wxGraphicsContext()Font=wxFont:wxFont()Colour=wx:wx_colour()
Sets the font for drawing text, now with colour energy π
Remark: For Direct2D only TrueType fonts can be used. π
setPen(This, Pen) -> ok
Types:
This=wxGraphicsContext()Pen=wxPen:wxPen() | wxGraphicsPen:wxGraphicsPen()
Sets the pen used for stroking. Line work main character energy βοΈ
strokeLine(This, X1, Y1, X2, Y2) -> ok
Types:
This=wxGraphicsContext()X1=Y1=X2=Y2=number()
Strokes a single line. One little line, one big slay π
strokeLines(This, Points) -> ok
Types:
This=wxGraphicsContext()Points=[{X :: float(), Y :: float()}]
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. So itβs one continuous path, not a bunch of separate little guys π
Thatβs the whole page, bestie π. Footer shoutout: wxWidgets team, wx 2.2.2.1, page wxGraphicsContext(3erl) β bye! β¨
π¦ where this page comes from
- ubuntu noble: erlang-manpages 1:25.3.2.8+dfsg-1ubuntu4 Β· Apache-2.0
- ubuntu noble: erlang-manpages 1:25.3.2.8+dfsg-1ubuntu4.8 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms