示例#1
0
    def __init__(self, text, insert=None, x=[], y=[], dx=[], dy=[], rotate=[],
                 **extra):
        """
        :param string text: **tspan** content
        :param 2-tuple insert: The **insert** parameter is the absolute insert point
                               of the text, don't use this parameter in combination
                               with the **x** or the **y** parameter.
        :param list x: list of absolute x-axis values for characters
        :param list y: list of absolute y-axis values for characters
        :param list dx: list of relative x-axis values for characters
        :param list dy: list of relative y-axis values for characters
        :param list rotate: list of rotation-values for characters (in degrees)

        """
        super(TSpan, self).__init__(**extra)
        self.text = text
        if insert is not None:
            if is_string(insert):
                raise TypeError("'insert' should be a <tuple> or a <list>  with" \
                                " at least two elements.")
            if x or y:
                raise ValueError("Use 'insert' and 'x' or 'y' parameter not" \
                                 " at the same time!")
            x = [insert[0]]
            y = [insert[1]]

        if x: self['x'] = strlist(list(iterflatlist(x)), ' ')
        if y: self['y'] = strlist(list(iterflatlist(y)), ' ')
        if dx: self['dx'] = strlist(list(iterflatlist(dx)), ' ')
        if dy: self['dy'] = strlist(list(iterflatlist(dy)), ' ')
        if rotate: self['rotate'] = strlist(list(iterflatlist(rotate)), ' ')
示例#2
0
    def set_value(self,
                  values,
                  calcMode=None,
                  keyTimes=None,
                  keySplines=None,
                  from_=None,
                  to=None,
                  by=None):
        """
        Set animation attributes :ref:`values`, :ref:`calcMode`, :ref:`keyTimes`,
        :ref:`keySplines`, :ref:`from`, :ref:`to` and :ref:`by`.
        """
        if values is not None:
            if not is_string(values):
                values = strlist(values, ';')
            self['values'] = values

        if calcMode is not None:
            self['calcMode'] = calcMode
        if keyTimes is not None:
            self['keyTimes'] = keyTimes
        if keySplines is not None:
            self['keySplines'] = keySplines
        if from_ is not None:
            self['from'] = from_
        if to is not None:
            self['to'] = to
        if by is not None:
            self['by'] = by
示例#3
0
文件: filters.py 项目: MichelMina/Wx
    def __init__(self, start=None, size=None, resolution=None, inherit=None, **extra):
        """
        :param 2-tuple start: defines the start point of the filter effects region (**x**, **y**)
        :param 2-tuple size: defines the size of the filter effects region (**width**, **height**)
        :param resolution: takes the form ``'x-pixels [y-pixels]'``, and indicates
            the width and height of the intermediate images in pixels.
        :param inherit: inherits properties from Filter `inherit` see: **xlink:href**

        """
        super(Filter, self).__init__(**extra)
        if start is not None:
            self['x'] = start[0]
            self['y'] = start[1]
        if size is not None:
            self['width'] = size[0]
            self['height'] = size[1]
        if resolution is not None:
            if is_string(resolution):
                self['filterRes'] = resolution
            elif hasattr(resolution, '__iter__'):
                self['filterRes'] = strlist(resolution, ' ')
            else:
                self['filterRes'] = str(resolution)

        if inherit is not None:
            self.href = inherit
            self.update_id()
示例#4
0
    def __init__(self, start=None, size=None, resolution=None, inherit=None, **extra):
        """
        :param 2-tuple start: defines the start point of the filter effects region (**x**, **y**)
        :param 2-tuple size: defines the size of the filter effects region (**width**, **height**)
        :param resolution: takes the form ``'x-pixels [y-pixels]'``, and indicates
            the width and height of the intermediate images in pixels.
        :param inherit: inherits properties from Filter `inherit` see: **xlink:href**

        """
        super(Filter, self).__init__(**extra)
        if start is not None:
            self['x'] = start[0]
            self['y'] = start[1]
        if size is not None:
            self['width'] = size[0]
            self['height'] = size[1]
        if resolution is not None:
            if is_string(resolution):
                self['filterRes'] = resolution
            elif hasattr(resolution, '__iter__'):
                self['filterRes'] = strlist(resolution, ' ')
            else:
                self['filterRes'] = str(resolution)

        if inherit is not None:
            self.href = inherit
            self.update_id()
示例#5
0
    def get_xml(self):
        """ Get the XML representation as `ElementTree` object.

        :return: XML `ElementTree` of this object and all its subelements

        """
        self.attribs['d'] = str(strlist(self.commands, ' '))
        return super(Path, self).get_xml()
示例#6
0
文件: path.py 项目: MindPass/Code
    def get_xml(self):
        """ Get the XML representation as `ElementTree` object.

        :return: XML `ElementTree` of this object and all its subelements

        """
        self.attribs['d'] = to_unicode(strlist(self.commands, ' '))
        return super(Path, self).get_xml()
示例#7
0
文件: mixins.py 项目: MindPass/Code
    def translate(self, tx, ty=None):
        """
        Specifies a translation by **tx** and **ty**. If **ty** is not provided,
        it is assumed to be zero.

        :param number tx: user coordinate - no units allowed
        :param number ty: user coordinate - no units allowed
        """
        self._add_transformation("translate(%s)" % strlist( [tx, ty] ))
示例#8
0
    def translate(self, tx, ty=None):
        """
        Specifies a translation by **tx** and **ty**. If **ty** is not provided,
        it is assumed to be zero.

        :param number tx: user coordinate - no units allowed
        :param number ty: user coordinate - no units allowed
        """
        self._add_transformation("translate(%s)" % strlist([tx, ty]))
示例#9
0
文件: mixins.py 项目: MindPass/Code
    def scale(self, sx, sy=None):
        """
        Specifies a scale operation by **sx** and **sy**. If **sy** is not
        provided, it is assumed to be equal to **sx**.

        :param number sx: scalar factor x-axis, no units allowed
        :param number sy: scalar factor y-axis, no units allowed

        """
        self._add_transformation("scale(%s)" % strlist( [sx, sy] ))
示例#10
0
    def scale(self, sx, sy=None):
        """
        Specifies a scale operation by **sx** and **sy**. If **sy** is not
        provided, it is assumed to be equal to **sx**.

        :param number sx: scalar factor x-axis, no units allowed
        :param number sy: scalar factor y-axis, no units allowed

        """
        self._add_transformation("scale(%s)" % strlist([sx, sy]))
示例#11
0
文件: mixins.py 项目: MindPass/Code
    def rotate(self, angle, center=None):
        """
        Specifies a rotation by **angle** degrees about a given point.
        If optional parameter **center** are not supplied, the rotate is
        about the origin of the current user coordinate system.

        :param number angle: rotate-angle in degrees
        :param 2-tuple center: rotate-center as user coordinate - no units allowed

        """
        self._add_transformation("rotate(%s)" % strlist( [angle, center] ))
示例#12
0
    def rotate(self, angle, center=None):
        """
        Specifies a rotation by **angle** degrees about a given point.
        If optional parameter **center** are not supplied, the rotate is
        about the origin of the current user coordinate system.

        :param number angle: rotate-angle in degrees
        :param 2-tuple center: rotate-center as user coordinate - no units allowed

        """
        self._add_transformation("rotate(%s)" % strlist([angle, center]))
示例#13
0
    def viewbox(self, minx=0, miny=0, width=0, height=0):
        """ Specify a rectangle in **user space** (no units allowed) which
        should be mapped to the bounds of the viewport established by the
        given element.

        :param number minx: left border of the viewBox
        :param number miny: top border of the viewBox
        :param number width: width of the viewBox
        :param number height: height of the viewBox

        """
        self['viewBox'] = strlist([minx, miny, width, height])
示例#14
0
文件: mixins.py 项目: MindPass/Code
    def viewbox(self, minx=0, miny=0, width=0, height=0):
        """ Specify a rectangle in **user space** (no units allowed) which
        should be mapped to the bounds of the viewport established by the
        given element.

        :param number minx: left border of the viewBox
        :param number miny: top border of the viewBox
        :param number width: width of the viewBox
        :param number height: height of the viewBox

        """
        self['viewBox'] = strlist( [minx, miny, width, height] )
示例#15
0
文件: mixins.py 项目: MindPass/Code
    def dasharray(self, dasharray=None, offset=None):
        """
        Set SVG Properties **stroke-dashoffset** and **stroke-dasharray**.

        Where *dasharray* specify the lengths of alternating dashes and gaps as
        <list> of <int> or <float> values or a <string> of comma and/or white
        space separated <lengths> or <percentages>. (e.g. as <list> dasharray=[1, 0.5]
        or as <string> dasharray='1 0.5')
        """
        if dasharray:
            self['stroke-dasharray'] = strlist(dasharray, ' ')
        if offset:
            self['stroke-dashoffset'] = offset
        return self
示例#16
0
    def dasharray(self, dasharray=None, offset=None):
        """
        Set SVG Properties **stroke-dashoffset** and **stroke-dasharray**.

        Where *dasharray* specify the lengths of alternating dashes and gaps as
        <list> of <int> or <float> values or a <string> of comma and/or white
        space separated <lengths> or <percentages>. (e.g. as <list> dasharray=[1, 0.5]
        or as <string> dasharray='1 0.5')
        """
        if dasharray is not None:
            self['stroke-dasharray'] = strlist(dasharray, ' ')
        if offset is not None:
            self['stroke-dashoffset'] = offset
        return self
示例#17
0
文件: animate.py 项目: MindPass/Code
    def set_value(self, values, calcMode=None, keyTimes=None, keySplines=None,
                  from_=None, to=None, by=None):
        """
        Set animation attributes :ref:`values`, :ref:`calcMode`, :ref:`keyTimes`,
        :ref:`keySplines`, :ref:`from`, :ref:`to` and :ref:`by`.
        """
        if values is not None:
            if not is_string(values):
                values = strlist(values, ';')
            self['values'] = values

        if calcMode is not None:
            self['calcMode'] = calcMode
        if keyTimes is not None:
            self['keyTimes'] = keyTimes
        if keySplines is not None:
            self['keySplines'] = keySplines
        if from_ is not None:
            self['from'] = from_
        if to is not None:
            self['to'] = to
        if by is not None:
            self['by'] = by
示例#18
0
 def test_basic_types(self):
     self.assertEqual(strlist([1, 2, 3]), "1,2,3")
     self.assertEqual(strlist([1, None, 3]), "1,3")
     self.assertEqual(strlist([1, 2, None]), "1,2")
示例#19
0
 def test_list(self):
     self.assertEqual(strlist([(5, 'abc', None), (1, 2, None)]),
                      "5,abc,1,2")
     self.assertEqual(strlist([(1, None, 3), 4]), "1,3,4")
示例#20
0
 def test_string(self):
     self.assertEqual(strlist("5,abc,1,2"), "5,abc,1,2")
示例#21
0
 def test_basic_types(self):
     self.assertEqual(strlist([1,2,3]), "1,2,3" )
     self.assertEqual(strlist([1,None,3]), "1,3")
     self.assertEqual(strlist([1,2,None]), "1,2")
示例#22
0
 def test_seperator(self):
     self.assertEqual(strlist([1,2,3], ' '), "1 2 3" )
     self.assertEqual(strlist([1,None,3], ';'), "1;3")
     self.assertEqual(strlist([1,2,None], ':'), "1:2")
示例#23
0
 def matrix(self, a, b, c, d, e, f):
     self._add_transformation("matrix(%s)" % strlist([a, b, c, d, e, f]))
示例#24
0
 def test_list(self):
     self.assertEqual(strlist( [(5, 'abc', None), (1, 2, None)] ), "5,abc,1,2")
     self.assertEqual(strlist( [(1,None,3), 4]), "1,3,4")
示例#25
0
 def test_string(self):
     self.assertEqual(strlist("5,abc,1,2") , "5,abc,1,2")
示例#26
0
文件: mixins.py 项目: MindPass/Code
 def matrix(self, a, b, c, d, e, f):
     self._add_transformation("matrix(%s)" % strlist( [a, b, c, d, e, f] ))
示例#27
0
 def test_seperator(self):
     self.assertEqual(strlist([1, 2, 3], ' '), "1 2 3")
     self.assertEqual(strlist([1, None, 3], ';'), "1;3")
     self.assertEqual(strlist([1, 2, None], ':'), "1:2")