diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-07-15 16:17:50 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-07-15 16:17:50 -0700 |
commit | 2a408cc988e83353556a910a7dfe3cf021d7cd44 (patch) | |
tree | c566e1181157417f2cd09f18f4868d52839367d6 | |
parent | 839fa8a9359cd7b383555e57da2a7e3000dabe75 (diff) | |
parent | d009ad073f29d18d0b85d846e656bf21d27a1812 (diff) |
Merge pull request #1385 from fhd/zoom-if-360
Just zoom the surface if the angle is divisible by 360
-rw-r--r-- | src/library_sdl.js | 4 | ||||
-rw-r--r-- | tests/sdl_rotozoom.c | 3 | ||||
-rw-r--r-- | tests/sdl_rotozoom.png | bin | 437956 -> 431921 bytes |
3 files changed, 6 insertions, 1 deletions
diff --git a/src/library_sdl.js b/src/library_sdl.js index a4f15597..d14e433b 100644 --- a/src/library_sdl.js +++ b/src/library_sdl.js @@ -1096,7 +1096,11 @@ var LibrarySDL = { return ret; }, + rotozoomSurface__deps: ['zoomSurface'], rotozoomSurface: function(src, angle, zoom, smooth) { + if (angle % 360 === 0) { + return _zoomSurface(src, zoom, zoom, smooth); + } var srcData = SDL.surfaces[src]; var w = srcData.width * zoom; var h = srcData.height * zoom; diff --git a/tests/sdl_rotozoom.c b/tests/sdl_rotozoom.c index e81258d9..cdbdcc6f 100644 --- a/tests/sdl_rotozoom.c +++ b/tests/sdl_rotozoom.c @@ -6,7 +6,7 @@ #include "emscripten.h" #endif -const int numSprites = 8; +const int numSprites = 9; SDL_Surface *screen; SDL_Surface *sprite[numSprites]; @@ -41,6 +41,7 @@ int main(int argc, char **argv) { sprite[5] = rotozoomSurface(sprite[1], 45, 0.5, SMOOTHING_ON); sprite[6] = zoomSurface(sprite[0], -0.5, 0.5, SMOOTHING_ON); sprite[7] = zoomSurface(sprite[0], -0.5, -0.5, SMOOTHING_ON); + sprite[8] = rotozoomSurface(sprite[1], 0, 0.5, SMOOTHING_ON); mainloop(); diff --git a/tests/sdl_rotozoom.png b/tests/sdl_rotozoom.png Binary files differindex 5c5dec2f..288dd303 100644 --- a/tests/sdl_rotozoom.png +++ b/tests/sdl_rotozoom.png |