Преглед на файлове

* libee/sprite.c:

+ Added sanity checks in ee_sprite_* functions.
  * libee/conic.c:
    + Use ellipsepoints() in ee_draw_circle().
tags/v0.99.beta14
Sam Hocevar sam преди 21 години
родител
ревизия
67a16319c6
променени са 2 файла, в които са добавени 27 реда и са изтрити 18 реда
  1. +12
    -17
      libee/conic.c
  2. +15
    -1
      libee/sprite.c

+ 12
- 17
libee/conic.c Целия файл

@@ -26,6 +26,8 @@

#include "ee.h"

static void ellipsepoints(int, int, int, int, char);

void ee_draw_circle(int x, int y, int r, char c)
{
int test, dx, dy;
@@ -33,28 +35,13 @@ void ee_draw_circle(int x, int y, int r, char c)
/* Optimized Bresenham. Kick ass. */
for(test = 0, dx = 0, dy = r ; dx <= dy ; dx++)
{
ee_putcharTO(x + dx, y + dy / 2, c);
ee_putcharTO(x - dx, y + dy / 2, c);
ee_putcharTO(x + dx, y - dy / 2, c);
ee_putcharTO(x - dx, y - dy / 2, c);

ee_putcharTO(x + dy, y + dx / 2, c);
ee_putcharTO(x - dy, y + dx / 2, c);
ee_putcharTO(x + dy, y - dx / 2, c);
ee_putcharTO(x - dy, y - dx / 2, c);
ellipsepoints(x, y, dx, dy, c);
ellipsepoints(x, y, dy, dx, c);

test += test > 0 ? dx - dy-- : dx;
}
}

static void ellipsepoints(int xo, int yo, int x, int y, char c)
{
ee_putcharTO(xo + x, yo + y, c);
ee_putcharTO(xo - x, yo + y, c);
ee_putcharTO(xo + x, yo - y, c);
ee_putcharTO(xo - x, yo - y, c);
}

void ee_draw_ellipse(int xo, int yo, int a, int b, char c)
{
int d2;
@@ -97,3 +84,11 @@ void ee_draw_ellipse(int xo, int yo, int a, int b, char c)
}
}

static void ellipsepoints(int xo, int yo, int x, int y, char c)
{
ee_putcharTO(xo + x, yo + y, c);
ee_putcharTO(xo - x, yo + y, c);
ee_putcharTO(xo + x, yo - y, c);
ee_putcharTO(xo - x, yo - y, c);
}


+ 15
- 1
libee/sprite.c Целия файл

@@ -130,6 +130,9 @@ struct ee_sprite *ee_load_sprite(const char *file)

void ee_set_sprite_frame(struct ee_sprite *sprite, int f)
{
if(sprite == NULL)
return;

if(f < 0 || f >= sprite->nf)
return;

@@ -138,13 +141,21 @@ void ee_set_sprite_frame(struct ee_sprite *sprite, int f)

int ee_get_sprite_frame(struct ee_sprite *sprite)
{
if(sprite == NULL)
return -1;

return sprite->f;
}

void ee_draw_sprite(int x, int y, struct ee_sprite *sprite)
{
int i, j;
struct ee_frame *frame = &sprite->frames[sprite->f];
struct ee_frame *frame;

if(sprite == NULL)
return;

frame = &sprite->frames[sprite->f];

for(j = 0; j < frame->h; j++)
{
@@ -165,6 +176,9 @@ void ee_free_sprite(struct ee_sprite *sprite)
{
int i;

if(sprite == NULL)
return;

for(i = sprite->nf; i--;)
{
struct ee_frame *frame = &sprite->frames[i];


Зареждане…
Отказ
Запис