wxGraphicsContext(3)
π wxGraphicsContext π
okay so bestie, you clicked into wxGraphicsContext(3) β the Erlang module definition β and it's part 1 of 2, so buckle up, we're only getting started. π
β¨ NAME β¨
wxGraphicsContext β a wxGraphicsContext instance is the object that is drawn upon.
π¦ DESCRIPTION π¦
It is created by a renderer using wxGraphicsRenderer:createContext/2. And you can do that either directly with a renderer instance, or indirectly using the static convenience create/1 functions of wxGraphicsContext, which always delegate the whole task to the default renderer. lowkey convenient, highkey the move.
Remark (important, bestie π): for some renderers (like Direct2D or Cairo) the processing of drawing operations may be deferred. Like, a 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 your 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. it's giving "your art is in the vault until you open it" π«Ά
See:
wxGraphicsRenderer:createContext/2wxGCDCwxDC
This class is derived, and can use functions, from:
wxGraphicsObject
wxWidgets docs: wxGraphicsContext
πΈ DATA TYPES πΈ
wxGraphicsContext() :: wx:wx_object().
π FUNCTIONS π
clip(This, Region) -> ok
clip(This, Region) -> ok
when
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 π
: - The clipping region should be given in logical coordinates. - Calling this function can only make the clipping region smaller, never larger. one-way street fr fr. - You need to call resetClip/1 first if you want to set the clipping region exactly to the region specified. - If the resulting clipping region is empty, then all drawing upon the context is clipped out (all changes made by drawing operations are masked out). π gutted.
clip(This, X, Y, W, H) -> ok
clip(This, X, Y, W, H) -> ok
when
This :: wxGraphicsContext(),
X :: number(),
Y :: number(),
W :: number(),
H :: number().
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. same vibe, different args β¨
concatTransform(This, Matrix) -> ok
concatTransform(This, Matrix) -> ok
when
This :: wxGraphicsContext(),
Matrix ::
wxGraphicsMatrix:wxGraphicsMatrix().
Concatenates the passed in transform with the current transform of this context. stacking them like a lil outfit π§
create() -> wxGraphicsContext().
Create a lightweight context that can be used only for measuring text. that's it, that's the whole job, and it's iconic.
create(WindowDC) -> wxGraphicsContext()
create(WindowDC) -> wxGraphicsContext()
when
WindowDC ::
wxWindowDC:wxWindowDC() |
wxWindow:wxWindow() |
wxMemoryDC:wxMemoryDC() |
wxImage:wxImage().
Creates a wxGraphicsContext from a wxWindowDC.
See: wxGraphicsRenderer:createContext/2
createBrush(This, Brush) -> wxGraphicsBrush:wxGraphicsBrush()
createBrush(This, Brush) -> wxGraphicsBrush:wxGraphicsBrush()
when
This :: wxGraphicsContext(),
Brush :: wxBrush:wxBrush().
Creates a native brush from a wxBrush. glow up for your plain old brush, periodt. π
createFont(This, SizeInPixels, Facename)
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. look at those two clauses, dual-wielding fr. π¦
Remark: for Direct2D graphics fonts can be created from TrueType fonts only.
createFont(This, SizeInPixels, Facename, [Option]) -> wxGraphicsFont:wxGraphicsFont()
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 the overload taking wxFont is preferred β see wxGraphicsRenderer:createFont/4 for more details. trust, the other one ate. π
Remark: for Direct2D graphics fonts can be created from TrueType fonts only.
Since: 2.9.3
createLinearGradientBrush(This, X1, Y1, X2, Y2, Stops) -> wxGraphicsBrush:wxGraphicsBrush()
createLinearGradientBrush(This, X1, Y1, X2, Y2, Stops) ->
wxGraphicsBrush:wxGraphicsBrush()
when
This :: wxGraphicsContext(),
X1 :: number(),
Y1 :: number(),
X2 :: number(),
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.
createLinearGradientBrush(This, X1, Y1, X2, Y2, C1, C2) -> wxGraphicsBrush:wxGraphicsBrush()
createLinearGradientBrush(This, X1, Y1, X2, Y2, C1, C2) ->
wxGraphicsBrush:wxGraphicsBrush()
when
This :: wxGraphicsContext(),
X1 :: number(),
Y1 :: number(),
X2 :: number(),
Y2 :: number(),
C1 :: wx:wx_colour(),
C2 :: wx:wx_colour().
Creates a native brush with a linear gradient. The brush starts at (x1, y1) and ends at (x2, y2). Either just the start and end gradient colours (c1 and c2) or a full set of gradient 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. it's giving sunset behind the skyline π
createMatrix(This, [Option]) -> wxGraphicsMatrix:wxGraphicsMatrix()
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. no notes, just math doing math. β¨
createPath(This) -> wxGraphicsPath:wxGraphicsPath()
createPath(This) -> wxGraphicsPath:wxGraphicsPath()
when This :: wxGraphicsContext().
Creates a native graphics path which is initially empty. blank canvas energy, main character arc incoming. π
createPen(This, Pen) -> wxGraphicsPen:wxGraphicsPen()
createPen(This, Pen) -> wxGraphicsPen:wxGraphicsPen()
when
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 β because constructing one only to pass it to this method is wasteful. we love efficiency bestie π
createRadialGradientBrush(This, StartX, StartY, EndX, EndY, Radius, Stops) -> wxGraphicsBrush:wxGraphicsBrush()
createRadialGradientBrush(This, StartX, StartY, EndX, EndY,
Radius, Stops) ->
wxGraphicsBrush:wxGraphicsBrush()
when
This :: wxGraphicsContext(),
StartX :: number(),
StartY :: number(),
EndX :: number(),
EndY :: number(),
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.
createRadialGradientBrush(This, StartX, StartY, EndX, EndY, Radius, OColor, CColor) -> wxGraphicsBrush:wxGraphicsBrush()
createRadialGradientBrush(This, StartX, StartY, EndX, EndY,
Radius, OColor, CColor) ->
wxGraphicsBrush:wxGraphicsBrush()
when
This :: wxGraphicsContext(),
StartX :: number(),
StartY :: number(),
EndX :: number(),
EndY :: number(),
Radius :: number(),
OColor :: wx:wx_colour(),
CColor :: wx:wx_colour().
Creates a native brush with a radial gradient. The brush originates at (startX, startY) and ends on a circle around (endX, endY) with the given radius. The gradient may be specified either by its start and end colours oColor and cColor or by a full set of gradient 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. concentric circle moment, obsessed. π
destroy(This :: wxGraphicsContext()) -> ok.
Destroys the object. bye bestie π
drawBitmap(This, Bmp, X, Y, W, H) -> ok
drawBitmap(This, Bmp, X, Y, W, H) -> ok
when
This :: wxGraphicsContext(),
Bmp :: wxBitmap:wxBitmap(),
X :: number(),
Y :: number(),
W :: number(),
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" β that's literally what the source says, typo and all π)
drawEllipse π
drawEllipse(This, X, Y, W, H) -> ok
when
This :: wxGraphicsContext(),
X :: number(),
Y :: number(),
W :: number(),
H :: number().
Draws an ellipse. Slay.
drawIcon π
drawIcon(This, Icon, X, Y, W, H) -> ok
when
This :: wxGraphicsContext(),
Icon :: wxIcon:wxIcon(),
X :: number(),
Y :: number(),
W :: number(),
H :: number().
Draws the icon. Cute.
drawLines β¨
drawLines(This, Points, [Option]) -> ok
when
This :: wxGraphicsContext(),
Points :: [{X :: float(), Y :: float()}],
Option :: {fillStyle, wx:wx_enum()}.
Draws a polygon. (Yes, bestie, the function is named drawLines but it draws a polygon β iconic.)
drawPath π¦
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. Two-step glow-up.
drawRectangle πΈ
drawRectangle(This, X, Y, W, H) -> ok
when
This :: wxGraphicsContext(),
X :: number(),
Y :: number(),
W :: number(),
H :: number().
Draws a rectangle.
drawRoundedRectangle π
drawRoundedRectangle(This, X, Y, W, H, Radius) -> ok
when
This :: wxGraphicsContext(),
X :: number(),
Y :: number(),
W :: number(),
H :: number(),
Radius :: number().
Draws a rounded rectangle. Soft edges, main character energy.
drawText (basic) π
drawText(This, Str, X, Y) -> ok
when
This :: wxGraphicsContext(),
Str :: unicode:chardata(),
X :: number(),
Y :: number().
Draws text at the defined position.
drawText (angle or background brush) π
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. Two vibes: angle or background brush.
drawText (angle + background brush) π
drawText(This, Str, X, Y, Angle, BackgroundBrush) -> ok
when
This :: wxGraphicsContext(),
Str :: unicode:chardata(),
X :: number(),
Y :: number(),
Angle :: number(),
BackgroundBrush ::
wxGraphicsBrush:wxGraphicsBrush().
Draws text at the defined position. Maximum text drama.
fillPath π§
fillPath(This, Path, [Option]) -> ok
when
This :: wxGraphicsContext(),
Path :: wxGraphicsPath:wxGraphicsPath(),
Option :: {fillStyle, wx:wx_enum()}.
Fills the path with the current brush.
getPartialTextExtents π
getPartialTextExtents(This, Text) -> [number()]
when
This :: wxGraphicsContext(),
Text :: unicode:chardata().
Fills the widths array with the widths from the beginning of text to the corresponding character of text. Lowkey useful.
getTextExtent π
getTextExtent(This, Text) -> Result
when
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.
getTransform πͺ
getTransform(This) -> wxGraphicsMatrix:wxGraphicsMatrix()
when This :: wxGraphicsContext().
Gets the current transformation matrix of this context.
resetClip βοΈ
resetClip(This) -> ok when This :: wxGraphicsContext().
Resets the clipping to original shape.
rotate πͺοΈ
rotate(This, Angle) -> ok
when This :: wxGraphicsContext(), Angle :: number().
Rotates the current transformation matrix (in radians). Radians bestie, not degrees.
scale π
scale(This, XScale, YScale) -> ok
when
This :: wxGraphicsContext(),
XScale :: number(),
YScale :: number().
Scales the current transformation matrix.
setBrush ποΈ
setBrush(This, Brush) -> ok
when
This :: wxGraphicsContext(),
Brush ::
wxGraphicsBrush:wxGraphicsBrush() |
wxBrush:wxBrush().
Sets the brush for filling paths.
setFont (graphics font) π€
setFont(This, Font) -> ok
when
This :: wxGraphicsContext(),
Font :: wxGraphicsFont:wxGraphicsFont().
Sets the font for drawing text.
setFont (font + colour) π¨
setFont(This, Font, Colour) -> ok
when
This :: wxGraphicsContext(),
Font :: wxFont:wxFont(),
Colour :: wx:wx_colour().
Sets the font for drawing text.
Remark: For Direct2D only TrueType fonts can be used. No cap, that's a Direct2D thing.
setPen ποΈ
setPen(This, Pen) -> ok
when
This :: wxGraphicsContext(),
Pen :: wxPen:wxPen() |
wxGraphicsPen:wxGraphicsPen().
Sets the pen used for stroking.
setTransform πͺ
setTransform(This, Matrix) -> ok
when
This :: wxGraphicsContext(),
Matrix :: wxGraphicsMatrix:wxGraphicsMatrix().
Sets the current transformation matrix of this context.
strokeLine β
strokeLine(This, X1, Y1, X2, Y2) -> ok
when
This :: wxGraphicsContext(),
X1 :: number(),
Y1 :: number(),
X2 :: number(),
Y2 :: number().
Strokes a single line.
strokeLines γ°οΈ
strokeLines(This, Points) -> ok
when
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. Periodt.
strokePath π
strokePath(This, Path) -> ok
when
This :: wxGraphicsContext(),
Path :: wxGraphicsPath:wxGraphicsPath().
Strokes along a path with the current pen.
translate π
translate(This, Dx, Dy) -> ok
when
This :: wxGraphicsContext(),
Dx :: number(),
Dy :: number().
Translates the current transformation matrix.
Shoutout to Ericsson AB for the wx 2.6 drop, and this iconic page is wxGraphicsContext(3) β it's giving timeless. πβ¨
π¦ where this page comes from
- ubuntu stonking: erlang-doc 1:29.0.6+dfsg-1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms