/* This file was generated by scramble.py. */
#include "draw.h"
#include "scramble.h"
void draw_circle(Image *rgb, int x, int y, int x_, int y_, Color c)
{
    float a = 0.5 * (x_ - x);
    float b = 0.5 * (y_ - y);
    float cx = x + a;
    float cy = y + b;
    /* circle radius */
    int n = 2 * pi * a;
    /* account for more/less pixels */
    n += (b - a) * 2;
    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 && py > 0 && px < rgb->w && py < rgb->h)
        {
            rgb->data.rgb[py * rgb->w + px] = c;
        }
    }
}
void draw_hline(Image *rgb, int x, int y, int 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;
    }
}
void draw_vline(Image *rgb, int x, int y, int 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;
    }
}
void draw_blank(Image *rgb, int x, int y, int w, int h, Color c)
{
    for (int i = 0; i < h; i++)
    {
        draw_hline(rgb, x, y + i, w, c);
    }
}
void draw_location(Image *rgb, int x, int y, Color c)
{
    draw_hline(rgb, x - 3, y, 7, c);
    draw_vline(rgb, x, y - 3, 7, c);
}
/* This file was generated by scramble.py. */
