wxGraphicsContext

wxGraphicsContext

wxGraphicsContext
Functions for wxGraphicsContext class

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

Create a lightweight context that can be used only for measuring text.

Types

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

Types

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

Types

SizeInPixels = number()
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

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:

Types

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.

Types

Resets the clipping to original shape.

Types

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.

Types

X = Y = W = H = Radius = number()

Draws a rounded rectangle.

Types

XScale = YScale = number()

Scales the current transformation matrix.

Types

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.