summaryrefslogtreecommitdiffstats
path: root/share/extensions/inkex/deprecated-simple/simplepath.py
blob: 97748f78e748941268e39aa53558e80cf56f8000 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# coding=utf-8
# COPYRIGHT
#
# pylint: disable=invalid-name
#
"""
Depreicated simplepath replacements with documentation
"""

import math
from inkex.deprecated import deprecate, DeprecatedDict
from inkex.transforms import Transform
from inkex.paths import Path

pathdefs = DeprecatedDict({
    'M':['L', 2, [float, float], ['x', 'y']],
    'L':['L', 2, [float, float], ['x', 'y']],
    'H':['H', 1, [float], ['x']],
    'V':['V', 1, [float], ['y']],
    'C':['C', 6, [float, float, float, float, float, float], ['x', 'y', 'x', 'y', 'x', 'y']],
    'S':['S', 4, [float, float, float, float], ['x', 'y', 'x', 'y']],
    'Q':['Q', 4, [float, float, float, float], ['x', 'y', 'x', 'y']],
    'T':['T', 2, [float, float], ['x', 'y']],
    'A':['A', 7, [float, float, float, int, int, float, float], ['r', 'r', 'a', 0, 's', 'x', 'y']],
    'Z':['L', 0, [], []]
})

@deprecate
def parsePath(d):
    """element.path.to_arrays()"""
    return Path(d).to_arrays()

@deprecate
def formatPath(a):
    """str(element.path) or str(Path(array))"""
    return str(Path(a))

@deprecate
def translatePath(p, x, y):
    """Path(array).translate(x, y)"""
    p[:] = Path(p).translate(x, y).to_arrays()

@deprecate
def scalePath(p, x, y):
    """Path(array).scale(x, y)"""
    p[:] = Path(p).scale(x, y).to_arrays()

@deprecate
def rotatePath(p, a, cx=0, cy=0):
    """Path(array).rotate(angle_degrees, (center_x, center_y))"""
    p[:] = Path(p).rotate(math.degrees(a), (cx, cy)).to_arrays()