Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/cairoutils.py
blob: 2dc425e7a32cbe6850ddf969cb4fa7df561e5a32 (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
def draw_round_rect(context, x, y, w, h, r):
    # Copiado de http://www.steveanddebs.org/PyCairoDemo/
    # "Draw a rounded rectangle"
    #   A****BQ
    #  H      C
    #  *      *
    #  G      D
    #   F****E

    # Move to A
    context.move_to(x + r, y)
    # Straight line to B
    context.line_to(x + w - r, y)
    # Curve to C, Control points are both at Q
    context.curve_to(x + w, y, x + w, y, x + w, y + r)
    # Move to D
    context.line_to(x + w, y + h - r)
    # Curve to E
    context.curve_to(x + w, y + h, x + w, y + h, x + w - r, y + h)
    # Line to F
    context.line_to(x + r, y + h)
    # Curve to G
    context.curve_to(x, y + h, x, y + h, x, y + h - r)
    # Line to H
    context.line_to(x, y + r)
    # Curve to A
    context.curve_to(x, y, x, y, x + r, y)
    return