summaryrefslogtreecommitdiff
path: root/src/px.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/px.c')
-rw-r--r--src/px.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/px.c b/src/px.c
index 5281432..d7c8650 100644
--- a/src/px.c
+++ b/src/px.c
@@ -220,10 +220,17 @@ _pxSpr(const PxSprArgs *args)
int h = (args->h < 0) ? (int)(args->spr->h) : (args->h);
h = pxMin(h, args->spr->h - args->iy);
+ int ox = args->x;
+ int oy = args->y;
+ if (args->center) {
+ ox -= w / 2;
+ oy -= h / 2;
+ }
+
for (int y = 0; y < h; y++) {
for (int x = 0; x < w; x++) {
- const int dx = x + args->x;
- const int dy = y + args->y;
+ const int dx = x + ox;
+ const int dy = y + oy;
int ix = args->ix + ((args->flip_x)
? (w - x - 1)
: (x));