source: libcaca/trunk/libee/graphics.c @ 153

Last change on this file since 153 was 153, checked in by Sam Hocevar, 20 years ago
  • libee/graphics.c: + Renamed ee_color() to ee_set_color(), wrote ee_get_color().
  • libee/line.c: + Implemented draw_polyline() and draw_thin_polyline().
  • libee/sprite.c: + Removed the f member of struct ee_sprite. + Implemented ee_get_sprite_{width|height|dx|dy}(). + Restore the color fater ee_draw_sprite() is called.
  • libee/box.c: + Fixed a bug causing improper box clipping at the right and the bottom.
  • data/foo_fighter: + Fixed bugs in the sprite.
  • src/intro.c: + Test effects for the future game's intro.
  • test/spritedit.c: + Added stuff to the sprite editor. We can now navigate through frames.
  • Property svn:keywords set to Id
File size: 2.1 KB
Line 
1/*
2 *   libee         ASCII-Art library
3 *   Copyright (c) 2002, 2003 Sam Hocevar <sam@zoy.org>
4 *                 All Rights Reserved
5 *
6 *   $Id: graphics.c 153 2003-11-12 01:48:58Z sam $
7 *
8 *   This program is free software; you can redistribute it and/or modify
9 *   it under the terms of the GNU General Public License as published by
10 *   the Free Software Foundation; either version 2 of the License, or
11 *   (at your option) any later version.
12 *
13 *   This program is distributed in the hope that it will be useful,
14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 *   GNU General Public License for more details.
17 *
18 *   You should have received a copy of the GNU General Public License
19 *   along with this program; if not, write to the Free Software
20 *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */
22
23#include "config.h"
24
25#ifdef USE_SLANG
26#   include <slang.h>
27#elif USE_NCURSES
28#   include <curses.h>
29#endif
30
31#include <string.h>
32#include <stdlib.h>
33
34#include "ee.h"
35
36static int ee_color = 0;
37
38void ee_set_color(int color)
39{
40    ee_color = color;
41#ifdef USE_SLANG
42    SLsmg_set_color(color);
43#elif USE_NCURSES
44    attrset(COLOR_PAIR(color));
45#else
46    /* Use dummy driver */
47#endif
48}
49
50int ee_get_color(void)
51{
52    return ee_color;
53}
54
55void ee_putchar(int x, int y, char c)
56{
57#ifdef USE_SLANG
58    SLsmg_gotorc(y,x);
59    SLsmg_write_char(c);
60#elif USE_NCURSES
61    move(y,x);
62    addch(c);
63#else
64    /* Use dummy driver */
65#endif
66}
67
68void ee_putstr(int x, int y, char *s)
69{
70#ifdef USE_SLANG
71    SLsmg_gotorc(y,x);
72    SLsmg_write_string(s);
73#elif USE_NCURSES
74    move(y,x);
75    addstr(s);
76#else
77    /* Use dummy driver */
78#endif
79}
80
81void ee_clear(void)
82{
83#if defined(USE_SLANG) || defined(USE_NCURSES)
84    /* We could use SLsmg_cls(), but drawing empty lines is much faster */
85    int x = ee_get_width(), y = ee_get_height();
86    char *empty_line = malloc((x + 1) * sizeof(char));
87
88    memset(empty_line, ' ', x);
89    empty_line[x] = '\0';
90
91    while(y--)
92    {
93        ee_putstr(0, y, empty_line);
94    }
95
96    free(empty_line);
97#else
98    /* Use dummy driver */
99#endif
100}
101
Note: See TracBrowser for help on using the repository browser.