Changeset 106 for ttyvaders


Ignore:
Timestamp:
Nov 9, 2003, 10:36:24 PM (16 years ago)
Author:
Sam Hocevar
Message:
  • libee/triangle.c: + Implemented ee_fill_triangle().
  • test/demo.c: + Triangle demo.
Location:
ttyvaders/trunk
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • ttyvaders/trunk/libee/Makefile.am

    r98 r106  
    2020        ee.h \
    2121        io.c \
     22        math.c \
     23        line.c \
    2224        circle.c \
    23         line.c \
    24         math.c \
     25        triangle.c \
    2526        $(NULL)
    2627libee_a_CPPFLAGS = $(CPPFLAGS_slang) $(CPPFLAGS_ncurses)
  • ttyvaders/trunk/libee/ee.h

    r104 r106  
    7474char ee_get_key(void);
    7575
    76 void ee_draw_circle(int, int, int, char);
    7776void ee_draw_line(int, int, int, int, char);
    7877void ee_draw_thin_line(int, int, int, int);
     78void ee_draw_circle(int, int, int, char);
     79void ee_fill_triangle(int, int, int, int, int, int, char);
    7980
    8081int ee_rand(int, int);
  • ttyvaders/trunk/test/Makefile.am

    r86 r106  
    2121
    2222demo_CPPFLAGS = -I../libee $(CPPFLAGS_slang) $(CPPFLAGS_ncurses)
    23 demo_LDADD = ../libee/libee.a $(LDFLAGS_slang) $(LDFLAGS_ncurses)
     23demo_LDADD = ../libee/libee.a $(LDFLAGS_slang) $(LDFLAGS_ncurses) -lm
    2424
  • ttyvaders/trunk/test/demo.c

    r104 r106  
    2121 */
    2222
     23#include "config.h"
     24
    2325#include <math.h>
    2426#include <string.h>
     
    3234static void demo_thin_lines(void);
    3335static void demo_circles(void);
     36static void demo_triangle(void);
    3437static void demo_radar(void);
    3538
     
    8386            case '5':
    8487                ee_clear();
     88                demo = demo_triangle;
     89                break;
     90            case '6':
     91                ee_clear();
    8592                demo = demo_radar;
    8693                break;
     
    124131    ee_putstr("4: circles demo");
    125132    ee_goto(4, 10);
    126     ee_putstr("5: radar demo");
     133    ee_putstr("5: triangle demo");
     134    ee_goto(4, 11);
     135    ee_putstr("6: radar demo");
    127136
    128137    ee_goto(4, yo - 2);
     
    217226        ee_draw_circle(x, y, r, '*');
    218227    }
     228
     229    ee_refresh();
     230}
     231
     232static void demo_triangle(void)
     233{
     234    static int i = 0;
     235
     236    int xo, yo, x1, y1, x2, y2, x3, y3;
     237
     238    i++;
     239
     240    xo = ee_get_width() * 5 / 8;
     241    yo = 2;
     242
     243    x1 = ee_get_width() / 8 + sin(0.03*i) * 5;
     244    y1 = ee_get_height() / 2 + cos(0.03*i) * 5;
     245
     246    x2 = ee_get_width() - 10 - cos(0.02*i) * 10;
     247    y2 = ee_get_height() - 5 + sin(0.02*i) * 5;
     248
     249    x3 = ee_get_width() / 4 - sin(0.02*i) * 5;
     250    y3 = ee_get_height() + cos(0.02*i) * 5;
     251
     252    ee_clear();
     253
     254    ee_color(EE_GREEN);
     255    ee_fill_triangle(xo, yo, x2, y2, x1, y1, '%');
     256    ee_color(EE_YELLOW);
     257    ee_draw_thin_line(xo, yo, x2, y2);
     258    ee_draw_thin_line(x2, y2, x1, y1);
     259    ee_draw_thin_line(x1, y1, xo, yo);
     260
     261    ee_color(EE_RED);
     262    ee_fill_triangle(x1, y1, x2, y2, x3, y3, '#');
     263    ee_color(EE_YELLOW);
     264    ee_draw_thin_line(x1, y1, x2, y2);
     265    ee_draw_thin_line(x2, y2, x3, y3);
     266    ee_draw_thin_line(x3, y3, x1, y1);
     267
     268    ee_color(EE_BLUE);
     269    ee_fill_triangle(xo, yo, x2, y2, x3, y3, '%');
     270    ee_color(EE_YELLOW);
     271    ee_draw_thin_line(xo, yo, x2, y2);
     272    ee_draw_thin_line(x2, y2, x3, y3);
     273    ee_draw_thin_line(x3, y3, xo, yo);
    219274
    220275    ee_refresh();
Note: See TracChangeset for help on using the changeset viewer.