/opt/cloudlinux/venv/lib/python3.11/site-packages/svgwrite
NameSizeModeActions
data/-0755rm
extensions/-0755rm
__pycache__/-0755rm
animate.py66630644editdlrm
base.py86240644editdlrm
container.py107410644editdlrm
drawing.py52910644editdlrm
elementfactory.py22970644editdlrm
etree.py13610644editdlrm
filters.py80020644editdlrm
gradients.py47020644editdlrm
image.py24930644editdlrm
masking.py18560644editdlrm
mixins.py107490644editdlrm
params.py19030644editdlrm
path.py28480644editdlrm
pattern.py19730644editdlrm
shapes.py53100644editdlrm
solidcolor.py17340644editdlrm
text.py81380644editdlrm
utils.py74210644editdlrm
validator2.py62050644editdlrm
version.py11190644editdlrm
__init__.py25060644editdlrm
Edit: /opt/cloudlinux/venv/lib/python3.11/site-packages/svgwrite/image.py (2493B)
#!/usr/bin/env python #coding:utf-8 # Author: mozman -- # Purpose: svg image element # Created: 09.10.2010 # Copyright (C) 2010, Manfred Moitzi # License: MIT License from svgwrite.base import BaseElement from svgwrite.mixins import Transform, _vert, _horiz, Clipping class Image(BaseElement, Transform, Clipping): """ The **image** element indicates that the contents of a complete file are to be rendered into a given rectangle within the current user coordinate system. The **image** element can refer to raster image files such as PNG or JPEG or to files with MIME type of "image/svg+xml". """ elementname = 'image' def __init__(self, href, insert=None, size=None, **extra): """ :param string href: hyperlink to the image resource :param 2-tuple insert: insert point (**x**, **y**) :param 2-tuple size: (**width**, **height**) :param dict attribs: additional SVG attributes :param extra: additional SVG attributes as keyword-arguments """ super(Image, self).__init__(**extra) self['xlink:href'] = href if insert is not None: self['x'] = insert[0] self['y'] = insert[1] if size is not None: self['width'] = size[0] self['height'] = size[1] def stretch(self): """ Stretch viewBox in x and y direction to fill viewport, does not preserve aspect ratio. """ self['preserveAspectRatio'] = 'none' def fit(self, horiz="center", vert="middle", scale="meet"): """ Set the preserveAspectRatio attribute. :param string horiz: horizontal alignment ``'left'|'center'|'right'`` :param string vert: vertical alignment ``'top'|'middle'|'bottom'`` :param string scale: scale method ``'meet'|'slice'`` ============= =========== Scale methods Description ============= =========== ``meet`` preserve aspect ration and zoom to limits of viewBox ``slice`` preserve aspect ration and viewBox touch viewport on all bounds, viewBox will extend beyond the bounds of the viewport ============= =========== """ if self.debug and scale not in ('meet', 'slice'): raise ValueError("Invalid scale parameter '%s'" % scale) self.attribs['preserveAspectRatio'] = "%s%s %s" % (_horiz[horiz],_vert[vert], scale)