File: __init__.py

package info (click to toggle)
python-enable 4.3.0-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 7,280 kB
  • ctags: 13,899
  • sloc: cpp: 48,447; python: 28,502; ansic: 9,004; makefile: 315; sh: 44
file content (47 lines) | stat: -rw-r--r-- 1,604 bytes parent folder | download | duplicates (3)
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
"""

"""
import math
import wx

from enable.savage.svg import svg_extras

def elliptical_arc_to(self, rx, ry, phi, large_arc_flag, sweep_flag, x2, y2):
    x1, y1 = self.GetCurrentPoint()
    arcs = svg_extras.elliptical_arc_to(self, rx, ry, phi,
                                        large_arc_flag, sweep_flag,
                                        x1, y1, x2, y2)
    for arc in arcs:
        path = wx.GraphicsRenderer_GetDefaultRenderer().CreatePath()
        path.MoveToPoint(x1, y1)
        path.AddCurveToPoint(*arc)

        self.AddPath(path)
        x1, y1 = self.GetCurrentPoint()
        self.MoveToPoint(x1, y1)
        self.CloseSubpath()


def AddEllipticalArc(self, x, y, width, height, theta, dtheta, clockwise=False):
    """ Draws an arc of an ellipse within bounding rect (x,y,w,h)
    from startArc to endArc (in degrees, relative to the horizontal line of the eclipse)"""

    # compute the cubic bezier and add that to the path by calling AddCurveToPoint
    sub_paths = svg_extras.bezier_arc(x, y, x+width, y+height, theta, dtheta)
    for sub_path in sub_paths:
        x1,y1, cx1, cy1, cx2, cy2, x2,y2 = sub_path

        path = wx.GraphicsRenderer_GetDefaultRenderer().CreatePath()
        path.MoveToPoint(x1, y1)
        path.AddCurveToPoint(cx1, cy1, cx2, cy2, x2, y2)

        self.AddPath(path)
        self.MoveToPoint(path.GetCurrentPoint())
        self.CloseSubpath()

if not hasattr(wx.GraphicsPath, "AddEllipticalArcTo"):
    wx.GraphicsPath.AddEllipticalArcTo = AddEllipticalArc
    wx.GraphicsPath.elliptical_arc_to = elliptical_arc_to

del AddEllipticalArc