Skip to content

Commit 1c9658f

Browse files
committed
Antialiasing is a new optional argument for sprite(). Default is off to prevent issues with transparent images.
1 parent fe42e74 commit 1c9658f

File tree

4 files changed

+7
-5
lines changed

4 files changed

+7
-5
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ Drawing functions:
5757
* text(x,y,string): print the specified text at x,y using a bitmap font.
5858
* triangle(x1,y1,x2,y2,x3,y3): draw a triangle with the specified vertex.
5959
* getpixel(x,y): return the red,gree,blue value of the specified pixel.
60+
* sprite(file,x,y,[rotation],[antialiasing]): draw sprite at coordinates with the specified rotation (in degrees, default 0) and antialiasing (default false).
6061

6162
Control functions:
6263

framebuffer.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,10 @@ void bfWriteString(frameBuffer *fb, int xp, int yp, const char *s, int len, int
105105
* the same interface with load81.c. */
106106
#define SPRITE_MT "l81.sprite_mt"
107107

108-
void spriteBlit(frameBuffer *fb, void *sprite, int x, int y, int angle) {
108+
void spriteBlit(frameBuffer *fb, void *sprite, int x, int y, int angle, int aa) {
109109
SDL_Surface *s = sprite;
110110
if (s == NULL) return;
111-
if (angle) s = rotozoomSurface(s,angle,1,1);
111+
if (angle) s = rotozoomSurface(s,angle,1,aa);
112112
SDL_Rect dst = {x, fb->height-1-y - s->h, s->w, s->h};
113113
SDL_BlitSurface(s, NULL, fb->screen, &dst);
114114
if (angle) SDL_FreeSurface(s);

framebuffer.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ void bfWriteChar(frameBuffer *fb, int xp, int yp, int c, int r, int g, int b, in
3939
void bfWriteString(frameBuffer *fb, int xp, int yp, const char *s, int len, int r, int g, int b, int alpha);
4040

4141
/* Sprites */
42-
void spriteBlit(frameBuffer *fb, void *sprite, int x, int y, int angle);
42+
void spriteBlit(frameBuffer *fb, void *sprite, int x, int y, int angle, int aa);
4343
void *spriteLoad(lua_State *L, const char *filename);
4444
void initSpriteEngine(lua_State *L);
4545

load81.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -254,15 +254,16 @@ int getpixelBinding(lua_State *L) {
254254

255255
int spriteBinding(lua_State *L) {
256256
const char *filename;
257-
int x, y, angle;
257+
int x, y, angle, antialiasing;
258258
void *sprite;
259259

260260
filename = lua_tostring(L, 1);
261261
x = lua_tonumber(L, 2);
262262
y = lua_tonumber(L, 3);
263263
angle = luaL_optnumber(L,4,0);
264+
antialiasing = lua_toboolean(L,5);
264265
sprite = spriteLoad(L,filename);
265-
spriteBlit(l81.fb, sprite, x, y, angle);
266+
spriteBlit(l81.fb, sprite, x, y, angle, antialiasing);
266267
return 1;
267268
}
268269

0 commit comments

Comments
 (0)