/*
    Copyright (c) 2026 Christian Schoenebeck

    This file is part of "gigedit" and released under the terms of the
    GNU General Public License version 2.
*/

#include "draw.h"

/** @brief Draw rectangle with rounded corners.
 */
void geDrawBubble(const Cairo::RefPtr<Cairo::Context>& cr,
                  double x, double y, double w, double h, double cornerRadius)
{
    cr->begin_new_sub_path();

    const double x1 = x + w;
    const double y1 = y + h;

    cr->move_to(x + cornerRadius, y);

    cr->line_to(x1 - cornerRadius, y);
    cr->arc(x1 - cornerRadius, y + cornerRadius, cornerRadius, -M_PI / 2., 0.);

    cr->line_to(x1, y1 - cornerRadius);
    cr->arc(x1 - cornerRadius, y1 - cornerRadius, cornerRadius, 0., M_PI / 2.);

    cr->line_to(x + cornerRadius, y1);
    cr->arc(x + cornerRadius, y1 - cornerRadius, cornerRadius, M_PI / 2., M_PI);

    cr->line_to(x, y + cornerRadius);
    cr->arc(x + cornerRadius, y + cornerRadius, cornerRadius, M_PI, 3. * M_PI / 2.);

    cr->close_path();
}
