inkex.elements._meta module#
Provide extra utility to each svg element type specific to its type.
This is useful for having a common interface for each element which can give path, transform, and property access easily.
- class inkex.elements._meta.Defs[source]#
Bases:
inkex.elements._base.BaseElement
A header defs element, one per document
- tag_name = 'defs'#
- _abc_impl = <_abc._abc_data object>#
- class inkex.elements._meta.StyleElement[source]#
Bases:
inkex.elements._base.BaseElement
A CSS style element containing multiple style definitions
- tag_name = 'style'#
- _abc_impl = <_abc._abc_data object>#
- class inkex.elements._meta.Script[source]#
Bases:
inkex.elements._base.BaseElement
A javascript tag in SVG
- tag_name = 'script'#
- _abc_impl = <_abc._abc_data object>#
- class inkex.elements._meta.Desc[source]#
Bases:
inkex.elements._base.BaseElement
Description element
- tag_name = 'desc'#
- _abc_impl = <_abc._abc_data object>#
- class inkex.elements._meta.Title[source]#
Bases:
inkex.elements._base.BaseElement
Title element
- tag_name = 'title'#
- _abc_impl = <_abc._abc_data object>#
- class inkex.elements._meta.NamedView[source]#
Bases:
inkex.elements._base.BaseElement
The NamedView element is Inkscape specific metadata about the file
- tag_name = 'sodipodi:namedview'#
- property current_layer#
- property center#
Returns view_center in terms of document units
- add_guide(position, orient=True, name=None) inkex.elements._meta.Guide [source]#
Creates a new guide in this namedview
New in version 1.3.
- Parameters
position –
a float containing the y position for
orient is True
, or the x position fororient is False
. The position is specified in the post-1.0 coordinate system, i.e. y=0 is at the top left of the viewbox, positive y axis pointing down.Alternatively, the position may be given as Tuple (or VectorLike)
orient –
True for horizontal, False for Vertical
alternatively: Tuple / Vector specifying x and y coordinates of the normal vector of the guide, or the (clockwise) angle between the horizontal axis and the guide. Defaults to True (horizontal)
name – label of the guide
- Returns
the created guide
- new_guide(**kwargs)#
Deprecated -> .. deprecated:: 1.3
Use
add_guide()
instead.Creates a new guide in this namedview
- Parameters
position –
a float containing the y position for
orient is True
, or the x position fororient is False
Changed in version 1.2: Alternatively, the position may be given as Tuple (or VectorLike)
orient –
True for horizontal, False for Vertical
Changed in version 1.2: Tuple / Vector specifying x and y coordinates of the normal vector of the guide.
name – label of the guide
- Returns
the created guide
- new_unique_guide(**kwargs)#
Deprecated -> .. deprecated:: 1.3
Use
add_unique_guide()
instead.Add a guide iif there is no guide that looks the same.
New in version 1.2.
- add_unique_guide(position: inkex.transforms.Vector2d, orientation: inkex.transforms.Vector2d) Optional[inkex.elements._meta.Guide] [source]#
Add a guide iif there is no guide that looks the same.
New in version 1.3.
- Parameters
position – Position as Tuple / Vector
orientation – Tuple / Vector specifying x and y coordinates of the normal vector of the guide.
name – label of the guide
- get_similar_guide(other: inkex.elements._meta.Guide) Optional[inkex.elements._meta.Guide] [source]#
Check if the namedview contains a guide that looks identical to one defined by (position, orientation) and is not identity (same element) as the first one. If such a guide exists, return it; otherwise, return None.
New in version 1.2.
- _get_pages() List[inkex.elements._meta.Page] [source]#
Returns all page elements
- _equivalent_page() inkex.elements._meta.Page [source]#
Returns an unrooted page based on the viewbox dimensions
- get_pages() List[inkex.elements._meta.Page] [source]#
Returns a list of pages within the document. For single page documents, a detached page element with dimensions according to the viewbox will be returned.
New in version 1.2.
Changed in version 1.3: For single-page documents, this function now returns the viewbox dimensions.
- new_page(x, y, width, height, label=None)[source]#
Creates a new page in this namedview. Always add pages through this function to ensure that single-page documents are treated correctly.
New in version 1.2.
Changed in version 1.3: If none exists, a page element with the viewbox dimensions will be inserted before the new page.
- _abc_impl = <_abc._abc_data object>#
- class inkex.elements._meta.Guide[source]#
Bases:
inkex.elements._base.BaseElement
An inkscape guide
- tag_name = 'sodipodi:guide'#
- property orientation: inkex.transforms.Vector2d#
Vector normal to the guide, in the pre-1.0 coordinate system (y axis upwards)
New in version 1.2.
- property angle: float#
(Clockwise) angle between the guide and the horizontal axis in degrees (i.e. what Inkscape 1.2+ shows as “Angle” in the guide properties)
New in version 1.3.
- property is_horizontal#
- property is_vertical#
- property raw_position: inkex.transforms.Vector2d#
Position of the guide handle. The y coordinate is flipped and relative to the bottom of the viewbox, this is a remnant of the pre-1.0 coordinate system
- property point#
Deprecated -> Use raw_position or position instead
- property position: inkex.transforms.Vector2d#
Position of the guide handle in normal coordinates, i.e. (0,0) is at the top left corner of the viewbox, positive y axis pointing downwards.
This function can only be used for guides which are attached to a root svg element.
- classmethod new(pos_x, pos_y, angle, **attrs)[source]#
Create a new element, converting attrs values to strings.
- set_position(pos_x, pos_y, angle=None)[source]#
Move this guide to the given x,y position and optionally set its orientation. The coordinate system used is the post-1.0 coordinate system (origin in the top left corner, y axis pointing down), which also defines the sense of rotation.
The guide must be rooted for this function to be used. Preferably, use
inkex.elements._meta.add_guide()
to create a new guide.New in version 1.3.
- Parameters
pos_x (Union[str, int, float]) – x position of the guide’s reference point
pos_y (Union[str, int, float]) – y position of the guide’s reference point
angle (Union[str, float, int, tuple, list], optional) –
Angle may be a string, float or integer, which will set the clockwise angle between the horizontal axis and the guide.
Alternatively, it may be a pair of numbers (tuple) which will be set as normal vector.
If not given at all, the orientation remains unchanged. Defaults to None.
- Returns
the modified guide
- Return type
- move_to(**kwargs)#
Deprecated -> .. deprecated:: 1.3
Use
set_position()
instead.Move this guide to the given x,y position,
Angle may be a float or integer, which will change the orientation. Alternately, it may be a pair of numbers (tuple) which will set the orientation directly. If not given at all, the orientation remains unchanged.
- static guides_coincident(guide1, guide2)[source]#
Check if two guides defined by (position, orientation) and (opos, oor) look identical (i.e. the position lies on the other guide AND the guide is (anti)parallel to the other guide).
New in version 1.2.
- _abc_impl = <_abc._abc_data object>#
- class inkex.elements._meta.Metadata[source]#
Bases:
inkex.elements._base.BaseElement
Resource Description Framework (RDF) metadata
- tag_name = 'metadata'#
- property doc_title#
- property description#
Use elem.desc = value
Deprecated since version 1.1.
- property rights#
- property creator#
- property publisher#
- property contributor#
- property date#
- property source#
- property language#
- property relation#
- property coverage#
- property identifier#
- property tags#
- _abc_impl = <_abc._abc_data object>#
- class inkex.elements._meta.ForeignObject[source]#
Bases:
inkex.elements._base.BaseElement
SVG foreignObject element
- tag_name = 'foreignObject'#
- _abc_impl = <_abc._abc_data object>#
- class inkex.elements._meta.Switch[source]#
Bases:
inkex.elements._base.BaseElement
A switch element
- tag_name = 'switch'#
- _abc_impl = <_abc._abc_data object>#
- class inkex.elements._meta.Grid[source]#
Bases:
inkex.elements._base.BaseElement
A namedview grid child
- tag_name = 'inkscape:grid'#
- _abc_impl = <_abc._abc_data object>#
- class inkex.elements._meta.Page[source]#
Bases:
inkex.elements._base.BaseElement
A namedview page child
New in version 1.2.
- tag_name = 'inkscape:page'#
- property width#
- property height#
- property x#
- property y#
- _abc_impl = <_abc._abc_data object>#
- property bounding_box: inkex.transforms.BoundingBox#
Returns the bounding box of the page.