Esempio n. 1
0
 def _render_upper_outer_pie(self, draw: ImageDraw, x1: int,
                             y1: int) -> None:
     x3 = x1
     y3 = y1
     x4 = x1 + 2 * int(self.corner_radius * self.upper_outer_radius_x)
     y4 = y1 + 2 * int(self.corner_radius * self.upper_outer_radius_y)
     draw.pieslice(((x3, y3), (x4, y4)), 180, 270, fill=1)
Esempio n. 2
0
 def _render_lower_outer_pie(self, draw: ImageDraw, x1: int,
                             y2: int) -> None:
     x3 = x1
     y3 = y2 - 2 * int(self.corner_radius * self.lower_outer_radius_y)
     x4 = x1 + 2 * int(self.corner_radius * self.lower_outer_radius_x)
     y4 = y2
     draw.pieslice(((x3, y3), (x4, y4)), 90, 180, fill=1)
Esempio n. 3
0
 def _render_lower_inner_pie(self, draw: ImageDraw, x2: int,
                             y2: int) -> None:
     x3 = x2 - 2 * int(self.corner_radius * self.lower_inner_radius_x)
     y3 = y2 - 2 * int(self.corner_radius * self.lower_inner_radius_y)
     x4 = x2
     y4 = y2
     draw.pieslice(((x3, y3), (x4, y4)), 0, 90, fill=1)
Esempio n. 4
0
 def _render_upper_inner_pie(self, draw: ImageDraw, y1: int,
                             x2: int) -> None:
     x3 = x2 - 2 * int(self.corner_radius * self.upper_inner_radius_x)
     y3 = y1
     x4 = x2
     y4 = y1 + 2 * int(self.corner_radius * self.upper_inner_radius_y)
     draw.pieslice(((x3, y3), (x4, y4)), 270, 360, fill=1)
 def draw_func(draw: ImageDraw):
     point = position.to_img(image.dimensions)
     angle = -position.a if position.a is not None else 0
     coords = [point.x - r, point.y - r, point.x + r, point.y + r]
     draw.pieslice(coords,
                   angle + 90,
                   angle - 90,
                   outline="black",
                   fill=fill)
Esempio n. 6
0
def rounded_rectangle(draw: ImageDraw, xy, r, fill=None, outline=None):
    draw.rectangle([(xy[0][0], xy[0][1] + r), (xy[1][0], xy[1][1] - r)],
                   fill=fill,
                   outline=outline)
    draw.rectangle([(xy[0][0] + r, xy[0][1]), (xy[1][0] - r, xy[1][1])],
                   fill=fill,
                   outline=outline)
    draw.pieslice([xy[0], (xy[0][0] + r * 2, xy[0][1] + r * 2)],
                  180,
                  270,
                  fill=fill,
                  outline=outline)
    draw.pieslice([(xy[1][0] - r * 2, xy[1][1] - r * 2), xy[1]],
                  0,
                  90,
                  fill=fill,
                  outline=outline)
    draw.pieslice([(xy[0][0], xy[1][1] - r * 2), (xy[0][0] + r * 2, xy[1][1])],
                  90,
                  180,
                  fill=fill,
                  outline=outline)
    draw.pieslice([(xy[1][0] - r * 2, xy[0][1]), (xy[1][0], xy[0][1] + r * 2)],
                  270,
                  360,
                  fill=fill,
                  outline=outline)
Esempio n. 7
0
def rounded_rectangle(
        draw: ImageDraw, box: Tuple[int, int, int, int],
        radius: int,
        fill: Any = None,
        outline: Any = None) -> None:
    """Draw a rounded rectangle on the given image."""
    x1, y1, x2, y2 = box

    draw.rectangle(
        (x1 + radius, y1, x2 - radius, y2),
        fill=fill,
        outline=outline
    )

    draw.rectangle(
        (x1, y1 + radius, x2, y2 - radius),
        fill=fill,
        outline=outline
    )

    diameter = radius * 2

    draw.pieslice(
        (x1, y1, x1 + diameter, y1 + diameter),
        start=180,
        end=270,
        fill=fill,
        outline=outline
    )
    draw.pieslice(
        (x2 - diameter, y1, x2, y1 + diameter),
        start=270,
        end=360,
        fill=fill,
        outline=outline
    )
    draw.pieslice(
        (x2 - diameter, y2 - diameter, x2, y2),
        start=0,
        end=90,
        fill=fill,
        outline=outline
    )
    draw.pieslice(
        (x1, y2 - diameter, x1 + diameter, y2),
        start=90,
        end=180,
        fill=fill,
        outline=outline
    )
Esempio n. 8
0
File: og.py Progetto: seebog/bazaar
def rounded_rectangle(image_draw: ImageDraw,
                      xy,
                      corner_radius,
                      fill=None,
                      outline=None):
    upper_left_point = xy[0]
    bottom_right_point = xy[1]
    image_draw.rectangle(
        [(upper_left_point[0], upper_left_point[1] + corner_radius),
         (bottom_right_point[0], bottom_right_point[1] - corner_radius)],
        fill=fill,
        outline=outline)
    image_draw.rectangle(
        [(upper_left_point[0] + corner_radius, upper_left_point[1]),
         (bottom_right_point[0] - corner_radius, bottom_right_point[1])],
        fill=fill,
        outline=outline)
    image_draw.pieslice([
        upper_left_point,
        (upper_left_point[0] + corner_radius * 2,
         upper_left_point[1] + corner_radius * 2)
    ],
                        180,
                        270,
                        fill=fill,
                        outline=outline)
    image_draw.pieslice(
        [(bottom_right_point[0] - corner_radius * 2,
          bottom_right_point[1] - corner_radius * 2), bottom_right_point],
        0,
        90,
        fill=fill,
        outline=outline)
    image_draw.pieslice(
        [(upper_left_point[0], bottom_right_point[1] - corner_radius * 2),
         (upper_left_point[0] + corner_radius * 2, bottom_right_point[1])],
        90,
        180,
        fill=fill,
        outline=outline)
    image_draw.pieslice(
        [(bottom_right_point[0] - corner_radius * 2, upper_left_point[1]),
         (bottom_right_point[0], upper_left_point[1] + corner_radius * 2)],
        270,
        360,
        fill=fill,
        outline=outline)
Esempio n. 9
0
 def draw(self, draw: ImageDraw):
     draw.pieslice(self.points, self.start, self.end, self.fill,
                   self.outline)