.. include:: headings.inc .. _GraphicsRenderer: ========================================================================================================================================== |phoenix_title| **GraphicsRenderer** ========================================================================================================================================== A :ref:`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 (:ref:`GraphicsContext`, :ref:`GraphicsPath` etc) and can be retrieved through their :meth:`GraphicsObject.GetRenderer` method. Therefore you can create an additional instance of a path etc. by calling :meth:`GraphicsObject.GetRenderer` and then using the appropriate CreateXXX() function of that renderer. :: path = wx.GraphicsPath() # from somewhere brush = path.GetRenderer().CreateBrush(wx.BLACK_BRUSH) | |class_hierarchy| Inheritance Diagram ===================================== Inheritance diagram for class **GraphicsRenderer** .. raw:: html

Inheritance diagram of GraphicsRenderer

| |method_summary| Methods Summary ================================ ================================================================================ ================================================================================ :meth:`~GraphicsRenderer.CreateBitmap` Creates :ref:`GraphicsBitmap` from an existing :ref:`Bitmap`. :meth:`~GraphicsRenderer.CreateBitmapFromImage` Creates :ref:`GraphicsBitmap` from an existing :ref:`Image`. :meth:`~GraphicsRenderer.CreateBitmapFromNativeBitmap` Creates :ref:`GraphicsBitmap` from a native bitmap handle. :meth:`~GraphicsRenderer.CreateBrush` Creates a native brush from a :ref:`Brush`. :meth:`~GraphicsRenderer.CreateContext` Creates a :ref:`GraphicsContext` from a :ref:`Window`. :meth:`~GraphicsRenderer.CreateContextFromImage` Creates a :ref:`GraphicsContext` associated with a :ref:`Image`. :meth:`~GraphicsRenderer.CreateContextFromNativeContext` Creates a :ref:`GraphicsContext` from a native context. :meth:`~GraphicsRenderer.CreateContextFromNativeWindow` Creates a :ref:`GraphicsContext` from a native window. :meth:`~GraphicsRenderer.CreateFont` Creates a native graphics font from a :ref:`Font` and a text colour. :meth:`~GraphicsRenderer.CreateImageFromBitmap` Creates a :ref:`Image` from a :ref:`GraphicsBitmap`. :meth:`~GraphicsRenderer.CreateLinearGradientBrush` Creates a native brush with a linear gradient. :meth:`~GraphicsRenderer.CreateMatrix` Creates a native affine transformation matrix from the passed in values. :meth:`~GraphicsRenderer.CreateMeasuringContext` Creates a :ref:`GraphicsContext` that can be used for measuring texts only. :meth:`~GraphicsRenderer.CreatePath` Creates a native graphics path which is initially empty. :meth:`~GraphicsRenderer.CreatePen` Creates a native pen from a :ref:`Pen`. :meth:`~GraphicsRenderer.CreateRadialGradientBrush` Creates a native brush with a radial gradient. :meth:`~GraphicsRenderer.CreateSubBitmap` Extracts a sub-bitmap from an existing bitmap. :meth:`~GraphicsRenderer.GetCairoRenderer` :meth:`~GraphicsRenderer.GetDefaultRenderer` Returns the default renderer on this platform. ================================================================================ ================================================================================ | |api| Class API =============== .. class:: GraphicsRenderer(Object) A GraphicsRenderer is the instance corresponding to the rendering engine used. .. method:: CreateBitmap(self, bitmap) Creates :ref:`GraphicsBitmap` from an existing :ref:`Bitmap`. Returns an invalid NullGraphicsBitmap on failure. :param `bitmap`: :type `bitmap`: Bitmap :rtype: :ref:`GraphicsBitmap` .. method:: CreateBitmapFromImage(self, image) Creates :ref:`GraphicsBitmap` from an existing :ref:`Image`. This method is more efficient than converting :ref:`Image` to :ref:`Bitmap` first and then calling :meth:`CreateBitmap` but otherwise has the same effect. Returns an invalid NullGraphicsBitmap on failure. :param `image`: :type `image`: Image :rtype: :ref:`GraphicsBitmap` .. versionadded:: 2.9.3 .. method:: CreateBitmapFromNativeBitmap(self, bitmap) Creates :ref:`GraphicsBitmap` from a native bitmap handle. `bitmap` meaning is platform-dependent. Currently it's a GDI+ ``Bitmap`` pointer under MSW, ``CGImage`` pointer under OS X or a ``cairo_surface_t`` pointer when using Cairo under any platform. :param `bitmap`: :rtype: :ref:`GraphicsBitmap` .. method:: CreateBrush(self, brush) Creates a native brush from a :ref:`Brush`. :param `brush`: :type `brush`: Brush :rtype: :ref:`GraphicsBrush` .. method:: CreateContext(self, *args, **kw) |overload| **Overloaded Implementations**: **~~~** **CreateContext** `(self, window)` Creates a :ref:`GraphicsContext` from a :ref:`Window`. :param `window`: :type `window`: Window :rtype: :ref:`GraphicsContext` **~~~** **CreateContext** `(self, windowDC)` Creates a :ref:`GraphicsContext` from a :ref:`WindowDC`. :param `windowDC`: :type `windowDC`: WindowDC :rtype: :ref:`GraphicsContext` **~~~** **CreateContext** `(self, memoryDC)` Creates a :ref:`GraphicsContext` from a :ref:`MemoryDC`. :param `memoryDC`: :type `memoryDC`: MemoryDC :rtype: :ref:`GraphicsContext` **~~~** **CreateContext** `(self, printerDC)` Creates a :ref:`GraphicsContext` from a :ref:`PrinterDC`. :param `printerDC`: :type `printerDC`: PrinterDC :rtype: :ref:`GraphicsContext` **~~~** .. method:: CreateContextFromImage(self, image) Creates a :ref:`GraphicsContext` associated with a :ref:`Image`. This function is used by `Context.CreateFromImage()` and is not normally called directly. :param `image`: :type `image`: Image :rtype: :ref:`GraphicsContext` .. versionadded:: 2.9.3 .. method:: CreateContextFromNativeContext(self, context) Creates a :ref:`GraphicsContext` from a native context. This native context must be a CGContextRef for Core Graphics, a Graphics pointer for GDIPlus, or a cairo_t pointer for cairo. :param `context`: :rtype: :ref:`GraphicsContext` .. method:: CreateContextFromNativeWindow(self, window) Creates a :ref:`GraphicsContext` from a native window. :param `window`: :rtype: :ref:`GraphicsContext` .. method:: CreateFont(self, *args, **kw) |overload| **Overloaded Implementations**: **~~~** **CreateFont** `(self, font, col=BLACK)` Creates a native graphics font from a :ref:`Font` and a text colour. :param `font`: :type `font`: Font :param `col`: :type `col`: Colour :rtype: :ref:`GraphicsFont` **~~~** **CreateFont** `(self, sizeInPixels, facename, flags=FONTFLAG_DEFAULT, col=BLACK)` Creates a graphics font with the given characteristics. If possible, the :meth:`CreateFont` overload taking :ref:`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. :param `sizeInPixels`: Height of the font in user space units, i.e. normally pixels. Notice that this is different from the overload taking :ref:`Font` as :ref:`Font` size is specified in points. :type `sizeInPixels`: float :param `facename`: 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. :type `facename`: string :param `flags`: Combination of FontFlag enum elements. Currently only ``FONTFLAG_ITALIC`` and ``FONTFLAG_BOLD`` are supported. By default the normal font version is used. :type `flags`: int :param `col`: The font colour, black by default. :type `col`: Colour :rtype: :ref:`GraphicsFont` .. versionadded:: 2.9.3 **~~~** .. method:: CreateImageFromBitmap(self, bmp) Creates a :ref:`Image` from a :ref:`GraphicsBitmap`. This method is used by the more convenient :meth:`GraphicsBitmap.ConvertToImage` . :param `bmp`: :type `bmp`: GraphicsBitmap :rtype: :ref:`Image` .. method:: CreateLinearGradientBrush(self, x1, y1, x2, y2, stops) 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. :param `x1`: :type `x1`: float :param `y1`: :type `y1`: float :param `x2`: :type `x2`: float :param `y2`: :type `y2`: float :param `stops`: :type `stops`: GraphicsGradientStops :rtype: :ref:`GraphicsBrush` .. method:: 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. :param `a`: :type `a`: float :param `b`: :type `b`: float :param `c`: :type `c`: float :param `d`: :type `d`: float :param `tx`: :type `tx`: float :param `ty`: :type `ty`: float :rtype: :ref:`GraphicsMatrix` .. method:: CreateMeasuringContext(self) Creates a :ref:`GraphicsContext` that can be used for measuring texts only. No drawing commands are allowed. :rtype: :ref:`GraphicsContext` .. method:: CreatePath(self) Creates a native graphics path which is initially empty. :rtype: :ref:`GraphicsPath` .. method:: CreatePen(self, pen) Creates a native pen from a :ref:`Pen`. :param `pen`: :type `pen`: Pen :rtype: :ref:`GraphicsPen` .. method:: CreateRadialGradientBrush(self, xo, yo, xc, yc, radius, stops) 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. :param `xo`: :type `xo`: float :param `yo`: :type `yo`: float :param `xc`: :type `xc`: float :param `yc`: :type `yc`: float :param `radius`: :type `radius`: float :param `stops`: :type `stops`: GraphicsGradientStops :rtype: :ref:`GraphicsBrush` .. method:: CreateSubBitmap(self, bitmap, x, y, w, h) Extracts a sub-bitmap from an existing bitmap. Currently this function is implemented in the native MSW and OS X versions but not when using Cairo. :param `bitmap`: :type `bitmap`: GraphicsBitmap :param `x`: :type `x`: float :param `y`: :type `y`: float :param `w`: :type `w`: float :param `h`: :type `h`: float :rtype: :ref:`GraphicsBitmap` .. staticmethod:: GetCairoRenderer() :rtype: :ref:`GraphicsRenderer` .. staticmethod:: GetDefaultRenderer() Returns the default renderer on this platform. On OS X 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. :rtype: :ref:`GraphicsRenderer`