Defines | |
#define | oslSetImageTile(img, x0, y0, x1, y1) ({ (img)->offsetX0=(float)x0, (img)->offsetY0=(float)y0, (img)->offsetX1=(float)x1, (img)->offsetY1=(float)y1; (img)->stretchX = oslAbs((int)((float)((img)->offsetX1) - (float)((img)->offsetX0))), (img)->stretchY = oslAbs((int)((float)((img)->offsetY1) - (float)((img)->offsetY0))); }) |
#define | oslSetImageTileSize(img, x0, y0, x1, y1) ({ (img)->offsetX0=(float)(x0), (img)->offsetY0=(float)(y0), (img)->offsetX1=(float)(x0)+(float)(x1), (img)->offsetY1=(float)(y0)+(float)(y1), (img)->stretchX = (int)(x1), (img)->stretchY = (int)(y1); }) |
#define | oslResetImageTile(img) ({ (img)->offsetX0=0, (img)->offsetY0=0, (img)->offsetX1=(img)->sizeX, (img)->offsetY1=(img)->sizeY; (img)->stretchX = (img)->sizeX, (img)->stretchY = (img)->sizeY; }) |
#define | oslMirrorImageH(img) ({ float ___tmp; ___tmp = (img)->offsetX0; (img)->offsetX0 = (img)->offsetX1; (img)->offsetX1 = ___tmp; }) |
#define | oslMirrorImageV(img) ({ float ___tmp; ___tmp = (img)->offsetY0; (img)->offsetY0 = (img)->offsetY1; (img)->offsetY1 = ___tmp; }) |
#define | oslImageIsMirroredH(img) ((img)->offsetX1 > (img)->offsetX0) |
#define | oslImageIsMirroredV(img) ((img)->offsetY1 > (img)->offsetY0) |
#define | oslImageRotMoveX(img, x) ((((x)+(img)->centerX*(img)->stretchX)/(img)->sizeX)) |
#define | oslImageRotMoveY(img, y) ((((y)+(img)->centerY*(img)->stretchY)/(img)->sizeY)) |
#define | oslSetImageRotCenter(img) ((img)->centerX=(int)oslAbs((img)->offsetX1-(img)->offsetX0)>>1, (img)->centerY=(int)oslAbs((img)->offsetY1-(img)->offsetY0)>>1) |
#define | oslImageSetRotCenter oslSetImageRotCenter |
#define | oslCorrectImageHalfBorder(img) ((img)->offsetX0 = (img)->offsetX0 + 0.5f, (img)->offsetY0 = (img)->offsetY0 + 0.5f, (img)->offsetX1 = (img)->offsetX1 - 0.5f, (img)->offsetY1 = (img)->offsetY1 - 0.5f, img->stretchX--, img->stretchY--) |
#define | oslResetImageHalfBorder(img) ((img)->offsetX0 = (img)->offsetX0 - 0.5f, (img)->offsetY0 = (img)->offsetY0 - 0.5f, (img)->offsetX1 = (img)->offsetX1 + 0.5f, (img)->offsetY1 = (img)->offsetY1 + 0.5f, img->stretchX++, img->stretchY++) |
#define | oslGetImageWidth(img) ((int)oslAbs((img)->offsetX1-(img)->offsetX0)) |
#define | oslGetImageHeight(img) ((int)oslAbs((img)->offsetY1-(img)->offsetY0)) |
#define oslSetImageTile | ( | img, | |||
x0, | |||||
y0, | |||||
x1, | |||||
y1 | ) | ({ (img)->offsetX0=(float)x0, (img)->offsetY0=(float)y0, (img)->offsetX1=(float)x1, (img)->offsetY1=(float)y1; (img)->stretchX = oslAbs((int)((float)((img)->offsetX1) - (float)((img)->offsetX0))), (img)->stretchY = oslAbs((int)((float)((img)->offsetY1) - (float)((img)->offsetY0))); }) |
Sets the source rectangle of the image to be displayed. Let's imagine you've got a big image (e.g. 128x128). This image contains in fact 16 "sprites" of 32x32 each. You can set it to display one of these with:
oslSetImageTile(image, 0, 0, 32, 32); oslDrawImage(image);
#define oslSetImageTileSize | ( | img, | |||
x0, | |||||
y0, | |||||
x1, | |||||
y1 | ) | ({ (img)->offsetX0=(float)(x0), (img)->offsetY0=(float)(y0), (img)->offsetX1=(float)(x0)+(float)(x1), (img)->offsetY1=(float)(y0)+(float)(y1), (img)->stretchX = (int)(x1), (img)->stretchY = (int)(y1); }) |
Same as oslSetImageTile except that x1 and y1 parameters are the size of the image rectangle. In case of 32x32 sprites it would always be 32, 32, and you would just set the x0, y0 coordinates to the beginning (top-left corner) of your sprite in the image.
#define oslResetImageTile | ( | img | ) | ({ (img)->offsetX0=0, (img)->offsetY0=0, (img)->offsetX1=(img)->sizeX, (img)->offsetY1=(img)->sizeY; (img)->stretchX = (img)->sizeX, (img)->stretchY = (img)->sizeY; }) |
Resets the image rectangle to its full (original) size.
#define oslMirrorImageH | ( | img | ) | ({ float ___tmp; ___tmp = (img)->offsetX0; (img)->offsetX0 = (img)->offsetX1; (img)->offsetX1 = ___tmp; }) |
Mirrors an image (or an image tile) horizontally. Note that mirroring twice reverts the image to its normal orientation. If you are calling this in a loop, don't forget to reset it after the image is drawn, else your image will be mirrored once per loop iteration and will appear ugly.
#define oslMirrorImageV | ( | img | ) | ({ float ___tmp; ___tmp = (img)->offsetY0; (img)->offsetY0 = (img)->offsetY1; (img)->offsetY1 = ___tmp; }) |
Mirrors an image vertically. Same remarks as oslMirrorImageH apply.
#define oslImageIsMirroredH | ( | img | ) | ((img)->offsetX1 > (img)->offsetX0) |
Return true if the image was mirrored horizontally.
#define oslImageIsMirroredV | ( | img | ) | ((img)->offsetY1 > (img)->offsetY0) |
Return true if the image was mirrored vertically.
#define oslImageRotMoveX | ( | img, | |||
x | ) | ((((x)+(img)->centerX*(img)->stretchX)/(img)->sizeX)) |
Moves the image so that its top-left corner appears at the specified x and y coordinates when angle is 0, taking in account rotation parameters.
#define oslImageRotMoveY | ( | img, | |||
y | ) | ((((y)+(img)->centerY*(img)->stretchY)/(img)->sizeY)) |
Same as oslImageRotMoveX but for the y coordinate.
#define oslSetImageRotCenter | ( | img | ) | ((img)->centerX=(int)oslAbs((img)->offsetX1-(img)->offsetX0)>>1, (img)->centerY=(int)oslAbs((img)->offsetY1-(img)->offsetY0)>>1) |
Sets the rotation center (centerX, centerY properties) to the center of the image. Useful for rotation as it seems usually normal that the rotation center is the middle of the image in question.
#define oslImageSetRotCenter oslSetImageRotCenter |
Alias for oslSetImageRotCenter.
#define oslCorrectImageHalfBorder | ( | img | ) | ((img)->offsetX0 = (img)->offsetX0 + 0.5f, (img)->offsetY0 = (img)->offsetY0 + 0.5f, (img)->offsetX1 = (img)->offsetX1 - 0.5f, (img)->offsetY1 = (img)->offsetY1 - 0.5f, img->stretchX--, img->stretchY--) |
Awful hacky routine, which crops 0.5 pixel to each image corner. This is useful if bilinear filtering is turned on and the image is stretched. In this case, by interpolation, the GPU may add a border to the image, which looks bad. This routine will make sure that this border won't be displayed.
#define oslResetImageHalfBorder | ( | img | ) | ((img)->offsetX0 = (img)->offsetX0 - 0.5f, (img)->offsetY0 = (img)->offsetY0 - 0.5f, (img)->offsetX1 = (img)->offsetX1 + 0.5f, (img)->offsetY1 = (img)->offsetY1 + 0.5f, img->stretchX++, img->stretchY++) |
Undoes the effect of oslCorrectImageHalfBorder. Rather use oslResetImageTile, this one will mess your image up if you're calling it twice or if you call without having called oslCorrectImageHalfBorder before.
#define oslGetImageWidth | ( | img | ) | ((int)oslAbs((img)->offsetX1-(img)->offsetX0)) |
Returns the image width, taking in account the frame (tile). You can retrieve the full image width with image->sizeX.
#define oslGetImageHeight | ( | img | ) | ((int)oslAbs((img)->offsetY1-(img)->offsetY0)) |
Returns the image height, taking in account the frame (tile). You can get the full image height with image->sizeY.