OldSchool Library
|
Macros | |
#define | oslSetImageTile(img, x0, y0, x1, y1) |
Sets the source rectangle of the image to be displayed. | |
#define | oslSetImageTileSize(img, x0, y0, x1, y1) |
Sets the source rectangle of the image to be displayed using tile size. | |
#define | oslResetImageTile(img) |
Resets the image rectangle to its full (original) size. | |
#define | oslMirrorImageH(img) |
Mirrors an image (or an image tile) horizontally. | |
#define | oslMirrorImageV(img) |
Mirrors an image (or an image tile) vertically. | |
#define | oslImageIsMirroredH(img) |
Returns whether the image is mirrored horizontally. | |
#define | oslImageIsMirroredV(img) |
Returns whether the image is mirrored vertically. | |
#define | oslImageRotMoveX(img, x) |
Calculates the x-coordinate for moving an image so that its top-left corner is at the specified position when no rotation is applied. | |
#define | oslImageRotMoveY(img, y) |
Calculates the y-coordinate for moving an image so that its top-left corner is at the specified position when no rotation is applied. | |
#define | oslSetImageRotCenter(img) |
Sets the rotation center of an image to its center. | |
#define | oslImageSetRotCenter oslSetImageRotCenter |
Alias for oslSetImageRotCenter . | |
#define | oslCorrectImageHalfBorder(img) |
Crops 0.5 pixel from each corner of the image. | |
#define | oslResetImageHalfBorder(img) |
Undoes the effect of oslCorrectImageHalfBorder . | |
#define | oslGetImageWidth(img) |
Returns the width of the image, considering the current frame or tile. | |
#define | oslGetImageHeight(img) |
Returns the height of the image, considering the current frame or tile. | |
#define | oslGetImageSizeX oslGetImageWidth |
Returns the width of the image, considering the current frame or tile. | |
#define | oslGetImageSizeY oslGetImageHeight |
Returns the height of the image, considering the current frame or tile. | |
Image placement in OSLib.
#define oslSetImageTile | ( | img, | |
x0, | |||
y0, | |||
x1, | |||
y1 ) |
Sets the source rectangle of the image to be displayed.
This macro allows you to define a sub-region of a larger image to be rendered. This is useful when you have an image that contains multiple sprites or tiles arranged in a grid.
For example, if you have a 128x128 image containing 16 sprites of 32x32 each, you can use this macro to select and display a specific sprite:
This will display the portion of the image starting at (0,0) and ending at (32,32), rendering a 32x32 sprite. To display the next sprite to the right, you would use:
img | The image from which a tile is to be extracted. |
x0 | The x-coordinate of the top-left corner of the tile. |
y0 | The y-coordinate of the top-left corner of the tile. |
x1 | The x-coordinate of the bottom-right corner of the tile (exclusive). |
y1 | The y-coordinate of the bottom-right corner of the tile (exclusive). |
oslDrawImage
for rendering the Images with the selected tile. #define oslSetImageTileSize | ( | img, | |
x0, | |||
y0, | |||
x1, | |||
y1 ) |
Sets the source rectangle of the image to be displayed using tile size.
This macro allows you to define a sub-region of a larger image to be rendered by specifying the size of the tile directly. This simplifies the process of defining a tile or sprite within an image.
For example, if you have a 128x128 image containing 32x32 sprites, you can use this macro to select and display a specific sprite by setting the size of the tile:
This will display a 32x32 tile starting from (0,0) and ending at (32,32). To display a sprite starting at (32,0) with the same size, you would use:
img | The image from which a tile is to be extracted. |
x0 | The x-coordinate of the top-left corner of the tile. |
y0 | The y-coordinate of the top-left corner of the tile. |
x1 | The width of the tile. |
y1 | The height of the tile. |
oslDrawImage
for rendering the Images with the selected tile. #define oslResetImageTile | ( | img | ) |
Resets the image rectangle to its full (original) size.
This macro resets the portion of the image to be drawn to cover the entire image. It effectively cancels any previous tile or sub-region settings, allowing you to draw the full image again.
For example, if you previously set a specific tile or sub-region of the image using oslSetImageTile
or oslSetImageTileSize
, you can use this macro to revert to displaying the entire image.
img | The image whose rectangle is to be reset. |
sizeX
and sizeY
), effectively ignoring any previously set tile or sub-region settings.oslSetImageTile
and oslSetImageTileSize
for setting specific sub-regions of an Images. #define oslMirrorImageH | ( | img | ) |
Mirrors an image (or an image tile) horizontally.
This macro flips the image horizontally by swapping the offsetX0
and offsetX1
coordinates of the image. It effectively mirrors the image along the vertical axis. If this macro is used in a loop or multiple times, make sure to reset the mirroring after drawing the image to avoid undesired effects, as each application of this macro will mirror the image again.
For example, if you want to mirror an image horizontally and then reset it to its original orientation, you might use:
img | The image to be mirrored. |
oslMirrorImageV
to mirror an Images vertically. #define oslMirrorImageV | ( | img | ) |
Mirrors an image (or an image tile) vertically.
This macro flips the image vertically by swapping the offsetY0
and offsetY1
coordinates of the image. It effectively mirrors the image along the horizontal axis. If this macro is used in a loop or multiple times, make sure to reset the mirroring after drawing the image to avoid undesired effects, as each application of this macro will mirror the image again.
For example, if you want to mirror an image vertically and then reset it to its original orientation, you might use:
img | The image to be mirrored. |
oslMirrorImageH
to mirror an Images horizontally. #define oslImageIsMirroredH | ( | img | ) |
Returns whether the image is mirrored horizontally.
This macro checks if the image has been mirrored horizontally. An image is considered to be mirrored horizontally if the x-coordinate of the bottom-right corner (offsetX1
) is greater than the x-coordinate of the top-left corner (offsetX0
).
img | The image to check for horizontal mirroring. |
true
if the image was mirrored horizontally, false
otherwise.oslMirrorImageH
to mirror the Images horizontally. #define oslImageIsMirroredV | ( | img | ) |
Returns whether the image is mirrored vertically.
This macro checks if the image has been mirrored vertically. An image is considered to be mirrored vertically if the y-coordinate of the bottom-right corner (offsetY1
) is greater than the y-coordinate of the top-left corner (offsetY0
).
img | The image to check for vertical mirroring. |
true
if the image was mirrored vertically, false
otherwise.oslMirrorImageV
to mirror the Images vertically. #define oslImageRotMoveX | ( | img, | |
x ) |
Calculates the x-coordinate for moving an image so that its top-left corner is at the specified position when no rotation is applied.
This macro computes the x-coordinate for positioning an image's top-left corner at (x, y)
considering the image's rotation parameters. It takes into account the rotation center and the size of the image.
img | The image to position. |
x | The desired x-coordinate for the top-left corner of the image. |
oslImageRotMoveY
for the y-coordinate. #define oslImageRotMoveY | ( | img, | |
y ) |
Calculates the y-coordinate for moving an image so that its top-left corner is at the specified position when no rotation is applied.
This macro computes the y-coordinate for positioning an image's top-left corner at (x, y)
considering the image's rotation parameters. It takes into account the rotation center and the size of the image.
img | The image to position. |
y | The desired y-coordinate for the top-left corner of the image. |
oslImageRotMoveX
for the x-coordinate. #define oslSetImageRotCenter | ( | img | ) |
Sets the rotation center of an image to its center.
This macro sets the rotation center (centerX
, centerY
) to the middle of the image. This is useful for rotation operations where the center of rotation is typically the middle of the image.
img | The image to modify. |
oslImageSetRotCenter
as an alias for this macro. #define oslImageSetRotCenter oslSetImageRotCenter |
Alias for oslSetImageRotCenter
.
This macro is an alias for oslSetImageRotCenter
, setting the rotation center to the middle of the image.
img | The image to modify. |
oslSetImageRotCenter
for detailed documentation. #define oslCorrectImageHalfBorder | ( | img | ) |
Crops 0.5 pixel from each corner of the image.
This macro adjusts the image's borders to eliminate visual artifacts caused by bilinear filtering when the image is stretched. By cropping 0.5 pixel from each corner, it helps prevent unwanted borders that might appear around the image.
img | The image to correct. |
#define oslResetImageHalfBorder | ( | img | ) |
Undoes the effect of oslCorrectImageHalfBorder
.
This macro reverts the adjustments made by oslCorrectImageHalfBorder
. It should be used with caution, as calling it without a preceding oslCorrectImageHalfBorder
or calling it multiple times may lead to incorrect image adjustments.
img | The image to reset. |
oslResetImageTile
for more consistent behavior. #define oslGetImageWidth | ( | img | ) |
Returns the width of the image, considering the current frame or tile.
This macro computes the width of the image based on the current frame or tile settings. To retrieve the full image width, use image->sizeX
.
img | The image to measure. |
#define oslGetImageHeight | ( | img | ) |
Returns the height of the image, considering the current frame or tile.
This macro computes the height of the image based on the current frame or tile settings. To retrieve the full image height, use image->sizeY
.
img | The image to measure. |
#define oslGetImageSizeX oslGetImageWidth |
Returns the width of the image, considering the current frame or tile.
This macro is an alias for oslGetImageWidth
, providing the width of the image based on the current frame or tile settings. To get the full image width, use image->sizeX
.
img | The image to measure. |
#define oslGetImageSizeY oslGetImageHeight |
Returns the height of the image, considering the current frame or tile.
This macro is an alias for oslGetImageHeight
, providing the height of the image based on the current frame or tile settings. To get the full image height, use image->sizeY
.
img | The image to measure. |