.. wxPython Phoenix documentation
This file was generated by Phoenix's sphinx generator and associated
tools, do not edit by hand.
Copyright: (c) 2011-2020 by Total Control Software
License: wxWindows License
.. include:: headings.inc
.. currentmodule:: wx.svg._nanosvg
.. highlight:: python
.. _wx.svg._nanosvg.SVGimageBase:
==========================================================================================================================================
|phoenix_title| **wx.svg._nanosvg.SVGimageBase**
==========================================================================================================================================
A SVGimageBase can be created either from an SVG file or from an in-memory
buffer containing the SVG XML code. The result is a collection of cubic
bezier shapes, with fill, stroke, gradients, paths and other information.
This class is a Cython-based wrapper around the nanosvg ``NSVGimage`` structure,
providing just the basic wrapped functionality from nanosvg. Please see the
:class:`wx.svg.SVGimage` class for a derived implementation that adds
functionality for integrating with wxPython.
|
|class_hierarchy| Class Hierarchy
=================================
.. raw:: html
Inheritance diagram for class
SVGimageBase:
|
|sub_classes| Known Subclasses
==============================
:class:`wx.svg.SVGimage`
|
|method_summary| Methods Summary
================================
================================================================================ ================================================================================
:meth:`~wx.svg._nanosvg.SVGimageBase.CreateFromBytes` Loads an SVG image from a bytes object.
:meth:`~wx.svg._nanosvg.SVGimageBase.CreateFromFile` Loads an SVG image from a file.
:meth:`~wx.svg._nanosvg.SVGimageBase.Rasterize` Renders the SVG image to a ``bytes`` object as a series of RGBA values.
:meth:`~wx.svg._nanosvg.SVGimageBase.RasterizeToBuffer` Renders the SVG image to an existing buffer as a series of RGBA values.
================================================================================ ================================================================================
|
|property_summary| Properties Summary
=====================================
================================================================================ ================================================================================
:attr:`~wx.svg._nanosvg.SVGimageBase.height` Returns the height of the SVG image
:attr:`~wx.svg._nanosvg.SVGimageBase.shapes` A generator that iterates over the :class:`SVGshape` objects that comprise the SVG image
:attr:`~wx.svg._nanosvg.SVGimageBase.width` Returns the width of the SVG image
================================================================================ ================================================================================
|
|api| Class API
===============
.. class:: SVGimageBase(object)
A SVGimageBase can be created either from an SVG file or from an in-memory
buffer containing the SVG XML code. The result is a collection of cubic
bezier shapes, with fill, stroke, gradients, paths and other information.
This class is a Cython-based wrapper around the nanosvg ``NSVGimage`` structure,
providing just the basic wrapped functionality from nanosvg. Please see the
:class:`wx.svg.SVGimage` class for a derived implementation that adds
functionality for integrating with wxPython.
.. classmethod:: CreateFromBytes(type cls, bytes buffer, str units='px', float dpi=96, bool do_copy=True)
Loads an SVG image from a bytes object.
:param bytes `buffer`: object containing the SVG data
:param str `units`: One of: 'px', 'pt', 'pc' 'mm', 'cm', or 'in'
:param float `dpi`: controls how the unit conversion is done
:param bool `do_copy`: indicates if the given bytes object should be
copied to avoid in-place modification. This should be set to ``True`` if the given `buffer` object may ever be reused in any capacity.
If the given `buffer` will only be used once, and the cost of copying
it is problematic, then `do_copy` can be set to False.
:rtype: An instance of ``cls`` (usually a :class:`SVGimage`)
.. classmethod:: CreateFromFile(type cls, str filename, str units='px', float dpi=96)
Loads an SVG image from a file.
:param str `filename`: Name of the file to load the SVG image from
:param str `units`: One of: 'px', 'pt', 'pc' 'mm', 'cm', or 'in'
:param float `dpi`: controls how the unit conversion is done
:rtype: An instance of ``cls`` (usually a :class:`SVGimage`)
.. method:: Rasterize(self, float tx=0.0, float ty=0.0, float scale=1.0, int width=-1, int height=-1, int stride=-1) -> bytes
Renders the SVG image to a ``bytes`` object as a series of RGBA values.
:param float `tx`: Image horizontal offset (applied after scaling)
:param float `ty`: Image vertical offset (applied after scaling)
:param float `scale`: Image scale
:param int `width`: width of the image to render, defaults to width from the SVG file
:param int `height`: height of the image to render, defaults to height from the SVG file
:param int `stride`: number of bytes per scan line in the destination buffer, typically ``width * 4``
:returns: A bytearray object containing the raw RGBA pixel color values
.. method:: RasterizeToBuffer(self, buf, float tx=0.0, float ty=0.0, float scale=1.0, int width=-1, int height=-1, int stride=-1) -> bytes
Renders the SVG image to an existing buffer as a series of RGBA values.
The buffer object must support the Python buffer-protocol, be writable,
and be at least ``width * height * 4`` bytes long. Possibilities include
bytearrays, memoryviews, numpy arrays, etc.
:param `buf`: An object supporting the buffer protocol where the RGBA bytes will be written
:param float `tx`: Image horizontal offset (applied after scaling)
:param float `ty`: Image vertical offset (applied after scaling)
:param float `scale`: Image scale
:param int `width`: width of the image to render, defaults to width from the SVG file
:param int `height`: height of the image to render, defaults to height from the SVG file
:param int `stride`: number of bytes per scan line in the destination buffer, typically ``width * 4``
.. attribute:: height
Returns the height of the SVG image
.. attribute:: shapes
A generator that iterates over the :class:`SVGshape` objects that comprise the SVG image
.. attribute:: width
Returns the width of the SVG image