NewI\O arc_test

arc_test.nio is a small app that demonstrates drawing random colored circles, some filled, and with various levels of transparency. Press the ESC key to exit.

Here is a screenshot:

Here is the sourcecode:

/******************************************************************************
 *
 *    arc_test.c
 *
 *    Copyright (C) 2002, 2005  Chris Nystrom
 *
 *    This program is free software; you can redistribute it and/or modify
 *    it under the terms of the GNU General Public License as published by
 *    the Free Software Foundation; either version 2 of the License, or
 *    (at your option) any later version.
 *
 *    This program is distributed in the hope that it will be useful,
 *    but without any warranty whatsoever.
 *
 *    For more license information see:
 *
 *      http://www.gnu.org/copyleft/gpl.html
 *
 *    Contact Author at:
 *
 *    Chris Nystrom
 *    11013 Prairie Dove Circle
 *    Austin, Texas  78758
 *
 *    E-Mail: cnystrom@gmail.com
 *    Blog:   http://conversazione.blogspot.com
 *    AIM:    nystromchris
 *
 *    Soli Deo Gloria
 *
 */

#define W (640)
#define H (480)

#include "nio_lib.h"

int main(int argc, char *argv[])
{
        int i, font;
        color black, white;

        nio_app_init("arc_test", "0.1");

        black = nio_get_color("black");
        white = nio_get_color("white");

        nio_set_screen(W, H, black);

        font = nio_load_sys_font(NIO_DEFAULT_FONT,
                                 NIO_DEFAULT_PTSIZE,
                                 NIO_STYLE_NORMAL, white, black);

        nio_term_init(font, black, 10, 10, 24, 80);

        nio_set_write_wait(20000);

        for (i = 0; i < 10000; i++) {
                int key, x, y, r, alpha, fill;

                x = nio_rand_int(W);
                y = nio_rand_int(H);
                r = nio_rand_int(H);
                alpha = nio_rand_int(255);
                fill = nio_rand_bool();

                nio_draw_arc_rand(x, y, r, alpha, fill, TRUE);

                nio_printf_at(2, 2, TRUE, "%5d: %3d,%3d,%3d\n\n", i, x, y,
                              r);

                key = nio_get_key();

                if (key == ESC) {
                        nio_free_font(font);
                        nio_exit();
                        exit(0);
                }
        }

        nio_print("Hit any key to exit...", TRUE);

        i = nio_get_char(FALSE);

        nio_free_font(font);
        nio_exit();
        exit(0);
}


Updated: 01/25/06 ccn