inkex.extensions module#
A helper module for creating Inkscape effect extensions
This provides the basic generic types of extensions which most writers should use in their code. See below for the different types.
- class inkex.extensions.EffectExtension[source]#
Bases:
inkex.base.SvgThroughMixin
,inkex.base.InkscapeExtension
,abc.ABC
Takes the SVG from Inkscape, modifies the selection or the document and returns an SVG to Inkscape.
- _abc_impl = <_abc._abc_data object>#
- class inkex.extensions.GenerateExtension[source]#
Bases:
inkex.extensions.EffectExtension
Does not need any SVG, but instead just outputs an SVG fragment which is inserted into Inkscape, centered on the selection.
- container_label = ''#
- container_layer = False#
- generate()[source]#
Return an SVG fragment to be inserted into the selected layer of the document OR yield multiple elements which will be grouped into a container group element which will be given an automatic label and transformation.
- container_transform()[source]#
Generate the transformation for the container group, the default is to return the center position of the svg document or view port.
- create_container()[source]#
Return the container the generated elements will go into.
Default is a new layer or current layer depending on the
container_layer
flag.New in version 1.1.
- _abc_impl = <_abc._abc_data object>#
- class inkex.extensions.InputExtension[source]#
Bases:
inkex.base.SvgOutputMixin
,inkex.base.InkscapeExtension
Takes any type of file as input and outputs SVG which Inkscape can read.
Used in functions for Open
- class inkex.extensions.OutputExtension[source]#
Bases:
inkex.base.SvgInputMixin
,inkex.base.TempDirMixin
,inkex.base.InkscapeExtension
Takes the SVG from Inkscape and outputs it to something that’s not an SVG.
Used in functions for Save As
- preprocess(types_to_path=None, unlink_clones=True)[source]#
Preprocess the SVG into an export-friendly document by converting certain objects to path beforehand.
- Parameters
types_to_path (List[str], optional) – List of element types to convert to path. Defaults to all text elements and all non-path shape elements.
unlink_clones (bool, optional) – If clones should be unlinked. Defaults to True.
- Returns
_description_
- Return type
_type_
- class inkex.extensions.RasterOutputExtension[source]#
Bases:
inkex.base.InkscapeExtension
Takes a PNG from Inkscape and outputs it to another raster format.
New in version 1.1.
- class inkex.extensions.CallExtension(*args, **kwargs)[source]#
Bases:
inkex.base.TempDirMixin
,inkex.extensions.InputExtension
Call an external program to get the output
- input_ext = 'svg'#
- output_ext = 'svg'#
- class inkex.extensions.TemplateExtension[source]#
Bases:
inkex.extensions.EffectExtension
Provide a standard way of creating templates.
- size_rex = re.compile('([\\d.]*)(\\w\\w)?x([\\d.]*)(\\w\\w)?')#
- template_id = 'SVGRoot'#
- arg_size(unit='px')[source]#
Argument is a string of the form X[unit]xY[unit], default units apply when missing
- _abc_impl = <_abc._abc_data object>#
- class inkex.extensions.ColorExtension[source]#
Bases:
inkex.extensions.EffectExtension
A standard way to modify colours in an svg document.
- process_none = False#
- select_all: Tuple[Type[IBaseElement], ...] = (<class 'inkex.elements._base.ShapeElement'>,)#
- pass_rgba = False#
If true, color and opacity are processed together (as RGBA color) by
modify_color()
.If false (default), they are processed independently by modify_color and modify_opacity.
New in version 1.2.
- _abc_impl = <_abc._abc_data object>#