import image

def draw_circle(Image *rgb, int x, y, x_, y_, Color c):
    float a = 0.5 * (x_ - x)
    float b = 0.5 * (y_ - y)
    float cx = x + a
    float cy = y + b
    int n = 2 * pi * a # circle radius
    n += (b - a) * 2 # account for more/less pixels
    double da = 2 * pi / n
    double angle = 0
    for int i = 0; i < n; i++:
        int px = cx + round(a * cos(angle))
        int py = cy + round(b * sin(angle))
        angle += da
        if px > 0 and py > 0 and px < rgb->w and py < rgb->h:
            rgb->data.rgb[py * rgb->w + px] = c

def draw_hline(Image *rgb, int x, y, len, Color c):
    int w = rgb->w
    if x < 0:
        len += x
        x = 0
    if x + len > w:
        len = w - x
    if y < 0: return
    if y >= rgb->h: return
    if len <= 0: return
    for int i = 0; i < len; i++:
        rgb->data.rgb[x + i + y * w] = c

def draw_vline(Image *rgb, int x, y, len, Color c):
    int w = rgb->w
    if y < 0:
        len += y
        y = 0
    if y + len > rgb->h:
        len = rgb->h - y
    if x < 0: return
    if x >= w: return
    if len <= 0: return
    for int i = 0; i < len; i++:
        rgb->data.rgb[x + (y + i) * w] = c

def draw_blank(Image *rgb, int x, y, w, h, Color c):
    for int i = 0; i < h; i++:
        draw_hline(rgb, x, y + i, w, c)

def draw_location(Image *rgb, int x, y, Color c):
    draw_hline(rgb, x - 3, y, 7, c)
    draw_vline(rgb, x, y - 3, 7, c)