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 wx.svg.SVGimage class for a derived implementation that adds functionality for integrating with wxPython.


class_hierarchy Class Hierarchy

Inheritance diagram for class SVGimageBase:

sub_classes Known Subclasses

wx.svg.SVGimage


method_summary Methods Summary

Rasterize

Renders the SVG image to a bytes object as a series of RGBA values.

RasterizeToBuffer

Renders the SVG image to an existing buffer as a series of RGBA values.


property_summary Properties Summary

height

SVGimageBase.height: float

shapes

A generator that iterates over the SVGshape objects that comprise the SVG image

width

SVGimageBase.width: float


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 wx.svg.SVGimage class for a derived implementation that adds functionality for integrating with wxPython.


Methods

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.

Parameters:
  • tx (float) – Image horizontal offset (applied after scaling)

  • ty (float) – Image vertical offset (applied after scaling)

  • scale (float) – Image scale

  • width (int) – width of the image to render, defaults to width from the SVG file

  • height (int) – height of the image to render, defaults to height from the SVG file

  • stride (int) – number of bytes per scan line in the destination buffer, typically width * 4

Returns:

A bytearray object containing the raw RGBA pixel color values



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.

Parameters:
  • buf – An object supporting the buffer protocol where the RGBA bytes will be written

  • tx (float) – Image horizontal offset (applied after scaling)

  • ty (float) – Image vertical offset (applied after scaling)

  • scale (float) – Image scale

  • width (int) – width of the image to render, defaults to width from the SVG file

  • height (int) – height of the image to render, defaults to height from the SVG file

  • stride (int) – number of bytes per scan line in the destination buffer, typically width * 4


Properties

height

SVGimageBase.height: float

Returns the height of the SVG image



shapes

A generator that iterates over the SVGshape objects that comprise the SVG image



width

SVGimageBase.width: float

Returns the width of the SVG image