#include "eduwin.h"

static HWND canvas;

static void draw_shapes()
{
    canvas_clear(canvas, 255, 255, 255, 255);

    /* 矩形 */
    canvas_set_brush(canvas, 255, 100, 100, 200);
    canvas_fill_rect(canvas, 10, 10, 100, 60);
    canvas_set_pen(canvas, 255, 0, 0, 255, 2);
    canvas_draw_rect(canvas, 10, 10, 100, 60);

    canvas_set_brush(canvas, 100, 255, 100, 200);
    canvas_fill_rect(canvas, 130, 10, 100, 60);
    canvas_set_pen(canvas, 0, 180, 0, 255, 2);
    canvas_draw_rect(canvas, 130, 10, 100, 60);

    /* 椭圆 */
    canvas_set_brush(canvas, 100, 100, 255, 200);
    canvas_fill_ellipse(canvas, 10, 90, 100, 60);
    canvas_set_pen(canvas, 0, 0, 255, 255, 2);
    canvas_draw_ellipse(canvas, 10, 90, 100, 60);

    canvas_set_brush(canvas, 255, 255, 100, 200);
    canvas_fill_ellipse(canvas, 130, 90, 100, 60);
    canvas_set_pen(canvas, 200, 200, 0, 255, 2);
    canvas_draw_ellipse(canvas, 130, 90, 100, 60);

    /* 直线 */
    canvas_set_pen(canvas, 255, 0, 255, 255, 3);
    canvas_draw_line(canvas, 10, 170, 230, 170);
    canvas_set_pen(canvas, 0, 128, 128, 255, 2);
    canvas_draw_line(canvas, 10, 170, 10, 270);
    canvas_set_pen(canvas, 255, 128, 0, 255, 4);
    canvas_draw_line(canvas, 230, 170, 230, 270);

    /* 空心矩形和文字 */
    canvas_set_pen(canvas, 0, 0, 0, 255, 2);
    canvas_draw_rect(canvas, 10, 180, 100, 30);
    canvas_draw_text(canvas, L"Line", 35, 186, 0, 0, 0, 255, 16);

    canvas_set_pen(canvas, 0, 0, 0, 255, 1);
    canvas_draw_rect(canvas, 140, 180, 80, 30);
    canvas_draw_text(canvas, L"Text", 162, 186, 0, 0, 0, 255, 16);

    /* 多色文字 */
    canvas_draw_text(canvas, L"您好 eduwin!", 10, 240, 255, 0, 0, 255, 22);
    canvas_draw_text(canvas, L"Rect Ellipse Line", 10, 270, 0, 100, 200, 255, 14);

    /* clear_rect 演示 */
    canvas_set_brush(canvas, 200, 200, 200, 255);
    canvas_fill_rect(canvas, 250, 10, 180, 280);
    canvas_clear_rect(canvas, 270, 30, 140, 50, 100, 200, 50, 255);
    canvas_draw_text(canvas, L"clear_rect", 275, 45, 0, 0, 0, 255, 14);
}

int main(void)
{
    if (init_app() != 0)
        return 1;

    HWND win = create_window(L"Shape Test - All Shapes", 460, 340);
    if (!win)
        return 1;

    canvas = create_canvas(win, 10, 10, 440, 300);

    show_window(win);
    draw_shapes();
    run_app();
    return 0;
}
