| Module | Rubygame::Transform |
| In: |
ext/rubygame/rubygame_transform.c
|
The Transform module provides several methods for rotating, zooming (scaling), and flipping (mirroring) Surfaces.
NOTICE: Except for flip, all these methods require Rubygame to be compiled against the SDL_gfx library! Furthermore, rotozoom and rotozoom_size offer additional functionality if Rubygame was compiled against SDL_gfx version 2.0.13 or greater.
You can check if Rubygame was compiled against SDL_gfx (of any version) with the usable? method, or find the version of SDL_gfx that Rubygame was compiled against with the version method.
Flips the source surface horizontally (if flipXp is true), vertically (if flipYp is true), or both (if both are true). This operation is non-destructive; the original image can be perfectly reconstructed by flipping the resultant image again.
This operation does NOT require SDL_gfx.
A similar effect can (supposedly) be achieved by giving X or Y zoom factors of -1 to Transform.rotozoom (if compiled with SDL_gfx 2.0.13 or greater). Your mileage may vary.
Return a rotated and/or zoomed version of the given surface. Note that rotating a Surface anything other than a multiple of 90 degrees will cause the new surface to be larger than the original to accomodate the corners (which would otherwise extend beyond the surface).
This function takes these arguments:
| surface: | the source surface. |
| angle: | degrees to rotate counter-clockwise (negative for clockwise). |
| zoom: | scaling factor. If Rubygame was compiled with SDL_gfx >= 2.0.13, this can be an Array of 2 Numerics for separate X and Y scaling, and can be negative to indicate flipping horizontally or vertically. |
| smooth: | whether to anti-alias the new surface. This option can be omitted, in which case the surface will not be anti-aliased. If true, the new surface will be 32bit RGBA. |
Return the dimensions of the surface that would be returned if Transform.rotozoom() were called with a surface of the given size, and the same angle and zoom factors.
| size: | an Array with the hypothetical surface width and height (pixels) |
| angle: | degrees to rotate counter-clockwise (negative for clockwise). |
| zoom: | scaling factor. If Rubygame was compiled with SDL_gfx >= 2.0.13, this can be an Array of 2 Numerics for separate X and Y scaling, and can be negative to indicate flipping across Y and/or X axes. |
Returns true if the feature(s) associated with this module/class are available for use. This means that Rubygame was compiled and linked against the C library which provides the feature, i.e. SDL_gfx, SDL_image, or SDL_ttf.
If the features are not available (for example, if the libraries were not installed or detected when Rubygame was compiled), returns false.
Return the major, minor, and micro numbers for the version of SDL_gfx that Rubygame was compiled with. If Rubygame was not compiled with SDL_gfx, all version numbers will be 0 (zero), and you should not attempt to use the Transform module.
This allows for more flexible detection of the capabilities of the Transform module‘s base library, SDL_gfx. See also usable?.
Return a zoomed version of the given Surface.
This function takes these arguments:
| surface: | the surface to zoom |
| zoom: | the factor to scale by in both x and y directions, or an Array with separate x and y scale factors. |
| smooth: | whether to anti-alias the new surface. This option can be omitted, in which case the surface will not be anti-aliased. If true, the new surface will be 32bit RGBA. |
Return the dimensions of the surface that would be returned if Transform.zoom() were called with a surface of the given size, and the same zoom factors.
This function takes these arguments:
| size: | an Array with the hypothetical surface width and height (pixels) |
| zoom: | the factor to scale by in both x and y directions, or an Array with separate x and y scale factors. |