A wx.GraphicsRenderer is the instance corresponding to the rendering engine used.
There may be multiple instances on a system, if there are different rendering engines present, but there is always only one instance per engine. This instance is pointed back to by all objects created by it ( wx.GraphicsContext, wx.GraphicsPath etc.) and can be retrieved through their wx.GraphicsObject.GetRenderer
method. Therefore you can create an additional instance of a path etc. by calling wx.GraphicsObject.GetRenderer
and then using the appropriate CreateXXX() function of that renderer.
path = wx.GraphicsPath() # from somewhere
brush = path.GetRenderer().CreateBrush(wx.BLACK_BRUSH)
Creates wx.GraphicsBitmap from an existing wx.Bitmap. |
|
Creates wx.GraphicsBitmap from an existing wx.Image. |
|
Creates wx.GraphicsBitmap from a native bitmap handle. |
|
Creates a native brush from a wx.Brush. |
|
Creates a wx.GraphicsContext from a wx.Window. |
|
Creates a wx.GraphicsContext associated with a wx.Image. |
|
Creates a wx.GraphicsContext from a native context. |
|
Creates a wx.GraphicsContext from a native window. |
|
Creates a wx.GraphicsContext from a DC of unknown specific type. |
|
Creates a native graphics font from a wx.Font and a text colour. |
|
Creates a native graphics font from a wx.Font and a text colour. |
|
Creates a wx.Image from a wx.GraphicsBitmap. |
|
Creates a native brush with a linear gradient. |
|
Creates a native affine transformation matrix from the passed in values. |
|
Creates a wx.GraphicsContext that can be used for measuring texts only. |
|
Creates a native graphics path which is initially empty. |
|
Creates a native pen from its description. |
|
Creates a native brush with a radial gradient. |
|
Extracts a sub-bitmap from an existing bitmap. |
|
Returns Cairo renderer. |
|
Returns the default renderer on this platform. |
|
Returns Direct2D renderer (MSW and Python3 only). |
|
Returns GDI+ renderer (MSW only). |
|
Returns the name of the technology used by the renderer. |
|
Returns the name of the GraphicsRenderer class. |
|
Returns the version major, minor and micro/build of the technology used by the renderer. |
See |
|
See |
wx.
GraphicsRenderer
(Object)¶A GraphicsRenderer is the instance corresponding to the rendering engine used.
CreateBitmap
(self, bitmap)¶Creates wx.GraphicsBitmap from an existing wx.Bitmap.
Returns an invalid NullGraphicsBitmap on failure.
bitmap (wx.Bitmap) –
CreateBitmapFromImage
(self, image)¶Creates wx.GraphicsBitmap from an existing wx.Image.
This method is more efficient than converting wx.Image to wx.Bitmap first and then calling CreateBitmap
but otherwise has the same effect.
Returns an invalid NullGraphicsBitmap on failure.
image (wx.Image) –
New in version 2.9.3.
CreateBitmapFromNativeBitmap
(self, bitmap)¶Creates wx.GraphicsBitmap from a native bitmap handle.
bitmap meaning is platform-dependent. Currently it’s a GDI+ Bitmap
pointer under MSW, CGImage
pointer under macOS or a cairo_surface_t
pointer when using Cairo under any platform.
Notice that this method takes ownership of bitmap, i.e. it will be destroyed when the returned wx.GraphicsBitmap is.
bitmap –
CreateBrush
(self, brush)¶Creates a native brush from a wx.Brush.
brush (wx.Brush) –
CreateContext
(self, *args, **kw)¶CreateContext (self, window)
Creates a wx.GraphicsContext from a wx.Window.
window (wx.Window) –
CreateContext (self, windowDC)
Creates a wx.GraphicsContext from a wx.WindowDC.
windowDC (wx.WindowDC) –
CreateContext (self, memoryDC)
Creates a wx.GraphicsContext from a wx.MemoryDC.
memoryDC (wx.MemoryDC) –
CreateContext (self, printerDC)
Creates a wx.GraphicsContext from a wx.PrinterDC.
printerDC (wx.PrinterDC) –
Note
Not implemented for Direct2D renderer (on MSW).
CreateContextFromImage
(self, image)¶Creates a wx.GraphicsContext associated with a wx.Image.
This function is used by Context.CreateFromImage() and is not normally called directly.
image (wx.Image) –
New in version 2.9.3.
CreateContextFromNativeContext
(self, context)¶Creates a wx.GraphicsContext from a native context.
This native context must be a CGContextRef for Core Graphics, a Graphics pointer for GDIPlus, an ID2D1RenderTarget pointer for Direct2D, a cairo_t pointer or HDC
for Cairo on MSW, or a cairo_t pointer for Cairo on any other platform.
context –
CreateContextFromNativeWindow
(self, window)¶Creates a wx.GraphicsContext from a native window.
window –
CreateContextFromUnknownDC
(self, dc)¶Creates a wx.GraphicsContext from a DC of unknown specific type.
Creates a wx.GraphicsContext if dc is a supported type (i.e. has a corresponding CreateContext
method, e.g. wx.WindowDC or wx.MemoryDC). Returns None
if the DC is unsupported.
This method is only useful as a helper in generic code that operates with wx.DC and doesn’t known its exact type. Use the appropriate CreateContext
overload instead if you know that the DC is e.g. wx.WindowDC.
dc (wx.DC) –
New in version 4.1/wxWidgets-3.1.3.
CreateFont
(self, *args, **kw)¶CreateFont (self, font, col=BLACK)
Creates a native graphics font from a wx.Font and a text colour.
CreateFont (self, sizeInPixels, facename, flags=FONTFLAG_DEFAULT, col=BLACK)
Creates a graphics font with the given characteristics.
If possible, the CreateFont
overload taking wx.Font should be used instead. The main advantage of this overload is that it can be used without X server connection under Unix when using Cairo.
sizeInPixels (float) – Height of the font in user space units, i.e. normally pixels. Notice that this is different from the overload taking wx.Font as wx.Font size is specified in points.
facename (string) – The name of the font. The same font name might not be available under all platforms so the font name can also be empty to use the default platform font.
flags (int) – Combination of FontFlag enum elements. Currently only FONTFLAG_ITALIC
and FONTFLAG_BOLD
are supported. By default the normal font version is used.
col (wx.Colour) – The font colour, black by default.
New in version 2.9.3.
CreateFontAtDPI
(self, font, dpi, col=BLACK)¶Creates a native graphics font from a wx.Font and a text colour.
The specified DPI
is used to convert the (fractional) wx.Font point-size to a fractional pixel-size.
font (wx.Font) –
dpi (wx.RealPoint) –
col (wx.Colour) –
New in version 4.1/wxWidgets-3.1.3.
CreateImageFromBitmap
(self, bmp)¶Creates a wx.Image from a wx.GraphicsBitmap.
This method is used by the more convenient wx.GraphicsBitmap.ConvertToImage
.
bmp (wx.GraphicsBitmap) –
CreateLinearGradientBrush
(self, x1, y1, x2, y2, stops, matrix=NullGraphicsMatrix)¶Creates a native brush with a linear gradient.
Stops support is new since wxWidgets 2.9.1, previously only the start and end colours could be specified.
The ability to apply a transformation matrix to the gradient was added in 3.1.3
x1 (wx.Double) –
y1 (wx.Double) –
x2 (wx.Double) –
y2 (wx.Double) –
stops (wx.GraphicsGradientStops) –
matrix (wx.GraphicsMatrix) –
CreateMatrix
(self, a=1.0, b=0.0, c=0.0, d=1.0, tx=0.0, ty=0.0)¶Creates a native affine transformation matrix from the passed in values.
The defaults result in an identity matrix.
a (wx.Double) –
b (wx.Double) –
c (wx.Double) –
d (wx.Double) –
tx (wx.Double) –
ty (wx.Double) –
CreateMeasuringContext
(self)¶Creates a wx.GraphicsContext that can be used for measuring texts only.
No drawing commands are allowed.
CreatePath
(self)¶Creates a native graphics path which is initially empty.
CreatePen
(self, info)¶Creates a native pen from its description.
info (wx.GraphicsPenInfo) –
New in version 4.1/wxWidgets-3.1.1.
CreateRadialGradientBrush
(self, startX, startY, endX, endY, radius, stops, matrix=NullGraphicsMatrix)¶Creates a native brush with a radial gradient.
Stops support is new since wxWidgets 2.9.1, previously only the start and end colours could be specified.
The ability to apply a transformation matrix to the gradient was added in 3.1.3
startX (wx.Double) –
startY (wx.Double) –
endX (wx.Double) –
endY (wx.Double) –
radius (wx.Double) –
stops (wx.GraphicsGradientStops) –
matrix (wx.GraphicsMatrix) –
CreateSubBitmap
(self, bitmap, x, y, w, h)¶Extracts a sub-bitmap from an existing bitmap.
bitmap (wx.GraphicsBitmap) –
x (wx.Double) –
y (wx.Double) –
w (wx.Double) –
h (wx.Double) –
GetCairoRenderer
()¶Returns Cairo renderer.
GetDefaultRenderer
()¶Returns the default renderer on this platform.
On macOS this is the Core Graphics (a.k.a. Quartz 2D
) renderer, on MSW the GDIPlus renderer, and on GTK we currently default to the Cairo renderer.
GetDirect2DRenderer
()¶Returns Direct2D renderer (MSW and Python3 only).
GetGDIPlusRenderer
()¶Returns GDI+ renderer (MSW only).
GetName
(self)¶Returns the name of the technology used by the renderer.
Currently this function returns “gdiplus” for Windows GDI+ implementation, “direct2d” for Windows Direct2D implementation, “cairo” for Cairo implementation and “cg” for macOS CoreGraphics implementation.
string
New in version 4.1/wxWidgets-3.1.0.
Note
The string returned by this method is not user-readable and is expected to be used internally by the program only.
GetType
(self)¶Returns the name of the GraphicsRenderer class.
GetVersion
(self, major, minor=None, micro=None)¶Returns the version major, minor and micro/build of the technology used by the renderer.
Currently this function returns the OS major and minor versions in the parameters with the matching names and sets micro to 0 for the GDI+ and CoreGraphics engines which are considered to be parts of their respective OS.
For Cairo, this is the major,minor,micro version of the Cairo library which is returned.
major (int) –
minor (int) –
micro (int) –