diff options
| author | raysan5 <[email protected]> | 2020-12-23 14:45:26 +0100 |
|---|---|---|
| committer | raysan5 <[email protected]> | 2020-12-23 14:45:26 +0100 |
| commit | 53a8ac406298e836470c66117de9b1838920901c (patch) | |
| tree | 61ea07abbb9a1558d8b0241eca1ba662779e6242 /cheatsheet/raylib_textures.c | |
| parent | 1e275f7857bc8834837d03fdec491d7be8a2c9b4 (diff) | |
| download | raylib.com-53a8ac406298e836470c66117de9b1838920901c.tar.gz raylib.com-53a8ac406298e836470c66117de9b1838920901c.zip | |
Update cheatsheet for raylib 3.5
Diffstat (limited to 'cheatsheet/raylib_textures.c')
| -rw-r--r-- | cheatsheet/raylib_textures.c | 56 |
1 files changed, 35 insertions, 21 deletions
diff --git a/cheatsheet/raylib_textures.c b/cheatsheet/raylib_textures.c index 3feb255..75efc7a 100644 --- a/cheatsheet/raylib_textures.c +++ b/cheatsheet/raylib_textures.c @@ -2,14 +2,12 @@ // Image loading functions // NOTE: This functions do not require GPU access Image LoadImage(const char *fileName); // Load image from file into CPU memory (RAM) - Image LoadImageEx(Color *pixels, int width, int height); // Load image from Color array data (RGBA - 32bit) - Image LoadImagePro(void *data, int width, int height, int format); // Load image from raw data with parameters Image LoadImageRaw(const char *fileName, int width, int height, int format, int headerSize); // Load image from RAW file data + Image LoadImageAnim(const char *fileName, int *frames); // Load image sequence from file (frames appended to image.data) + Image LoadImageFromMemory(const char *fileType, const unsigned char *fileData, int dataSize); // Load image from memory buffer, fileType refers to extension: i.e. "png" void UnloadImage(Image image); // Unload image from CPU memory (RAM) - void ExportImage(Image image, const char *fileName); // Export image data to file - void ExportImageAsCode(Image image, const char *fileName); // Export image as code file defining an array of bytes - Color *GetImageData(Image image); // Get pixel data from image as a Color struct array - Vector4 *GetImageDataNormalized(Image image); // Get pixel data from image as Vector4 array (float normalized) + bool ExportImage(Image image, const char *fileName); // Export image data to file, returns true on success + bool ExportImageAsCode(Image image, const char *fileName); // Export image as code file defining an array of bytes, returns true on success // Image generation functions Image GenImageColor(int width, int height, Color color); // Generate image: plain color @@ -26,16 +24,16 @@ Image ImageFromImage(Image image, Rectangle rec); // Create an image from another image piece Image ImageText(const char *text, int fontSize, Color color); // Create an image from text (default font) Image ImageTextEx(Font font, const char *text, float fontSize, float spacing, Color tint); // Create an image from text (custom sprite font) - void ImageToPOT(Image *image, Color fillColor); // Convert image to POT (power-of-two) void ImageFormat(Image *image, int newFormat); // Convert image data to desired format - void ImageAlphaMask(Image *image, Image alphaMask); // Apply alpha mask to image - void ImageAlphaClear(Image *image, Color color, float threshold); // Clear alpha channel to desired color + void ImageToPOT(Image *image, Color fill); // Convert image to POT (power-of-two) + void ImageCrop(Image *image, Rectangle crop); // Crop an image to a defined rectangle void ImageAlphaCrop(Image *image, float threshold); // Crop image depending on alpha value + void ImageAlphaClear(Image *image, Color color, float threshold); // Clear alpha channel to desired color + void ImageAlphaMask(Image *image, Image alphaMask); // Apply alpha mask to image void ImageAlphaPremultiply(Image *image); // Premultiply alpha channel - void ImageCrop(Image *image, Rectangle crop); // Crop an image to a defined rectangle void ImageResize(Image *image, int newWidth, int newHeight); // Resize image (Bicubic scaling algorithm) void ImageResizeNN(Image *image, int newWidth,int newHeight); // Resize image (Nearest-Neighbor scaling algorithm) - void ImageResizeCanvas(Image *image, int newWidth, int newHeight, int offsetX, int offsetY, Color color); // Resize canvas and fill with color + void ImageResizeCanvas(Image *image, int newWidth, int newHeight, int offsetX, int offsetY, Color fill); // Resize canvas and fill with color void ImageMipmaps(Image *image); // Generate all mipmap levels for a provided image void ImageDither(Image *image, int rBpp, int gBpp, int bBpp, int aBpp); // Dither image data to 16bpp or lower (Floyd-Steinberg dithering) void ImageFlipVertical(Image *image); // Flip image vertically @@ -48,7 +46,10 @@ void ImageColorContrast(Image *image, float contrast); // Modify image color: contrast (-100 to 100) void ImageColorBrightness(Image *image, int brightness); // Modify image color: brightness (-255 to 255) void ImageColorReplace(Image *image, Color color, Color replace); // Modify image color: replace color - Color *ImageExtractPalette(Image image, int maxPaletteSize, int *extractCount); // Extract color palette from image to maximum size (memory should be freed) + Color *LoadImageColors(Image image); // Load color data from image as a Color array (RGBA - 32bit) + Color *LoadImagePalette(Image image, int maxPaletteSize, int *colorsCount); // Load colors palette from image as a Color array (RGBA - 32bit) + void UnloadImageColors(Color *colors); // Unload color data loaded with LoadImageColors() + void UnloadImagePalette(Color *colors); // Unload colors palette loaded with LoadImagePalette() Rectangle GetImageAlphaBorder(Image image, float threshold); // Get image alpha border rectangle // Image drawing functions @@ -62,11 +63,11 @@ void ImageDrawCircleV(Image *dst, Vector2 center, int radius, Color color); // Draw circle within an image (Vector version) void ImageDrawRectangle(Image *dst, int posX, int posY, int width, int height, Color color); // Draw rectangle within an image void ImageDrawRectangleV(Image *dst, Vector2 position, Vector2 size, Color color); // Draw rectangle within an image (Vector version) - void ImageDrawRectangleRec(Image *dst, Rectangle rec, Color color); // Draw rectangle within an image + void ImageDrawRectangleRec(Image *dst, Rectangle rec, Color color); // Draw rectangle within an image void ImageDrawRectangleLines(Image *dst, Rectangle rec, int thick, Color color); // Draw rectangle lines within an image void ImageDraw(Image *dst, Image src, Rectangle srcRec, Rectangle dstRec, Color tint); // Draw a source image within a destination image (tint applied to source) - void ImageDrawText(Image *dst, Vector2 position, const char *text, int fontSize, Color color); // Draw text (default font) within an image (destination) - void ImageDrawTextEx(Image *dst, Vector2 position, Font font, const char *text, float fontSize, float spacing, Color color); // Draw text (custom sprite font) within an image (destination) + void ImageDrawText(Image *dst, const char *text, int posX, int posY, int fontSize, Color color); // Draw text (using default font) within an image (destination) + void ImageDrawTextEx(Image *dst, Font font, const char *text, Vector2 position, float fontSize, float spacing, Color tint); // Draw text (custom sprite font) within an image (destination) // Texture loading functions // NOTE: These functions require GPU access @@ -77,6 +78,7 @@ void UnloadTexture(Texture2D texture); // Unload texture from GPU memory (VRAM) void UnloadRenderTexture(RenderTexture2D target); // Unload render texture from GPU memory (VRAM) void UpdateTexture(Texture2D texture, const void *pixels); // Update GPU texture with new data + void UpdateTextureRec(Texture2D texture, Rectangle rec, const void *pixels); // Update GPU texture rectangle with new data Image GetTextureData(Texture2D texture); // Get pixel data from GPU texture and return an Image Image GetScreenData(void); // Get pixel data from screen buffer and return an Image (screenshot) @@ -89,12 +91,24 @@ void DrawTexture(Texture2D texture, int posX, int posY, Color tint); // Draw a Texture2D void DrawTextureV(Texture2D texture, Vector2 position, Color tint); // Draw a Texture2D with position defined as Vector2 void DrawTextureEx(Texture2D texture, Vector2 position, float rotation, float scale, Color tint); // Draw a Texture2D with extended parameters - void DrawTextureRec(Texture2D texture, Rectangle sourceRec, Vector2 position, Color tint); // Draw a part of a texture defined by a rectangle + void DrawTextureRec(Texture2D texture, Rectangle source, Vector2 position, Color tint); // Draw a part of a texture defined by a rectangle void DrawTextureQuad(Texture2D texture, Vector2 tiling, Vector2 offset, Rectangle quad, Color tint); // Draw texture quad with tiling and offset parameters - void DrawTexturePro(Texture2D texture, Rectangle sourceRec, Rectangle destRec, Vector2 origin, float rotation, Color tint); // Draw a part of a texture defined by a rectangle with 'pro' parameters - void DrawTextureNPatch(Texture2D texture, NPatchInfo nPatchInfo, Rectangle destRec, Vector2 origin, float rotation, Color tint); // Draws a texture (or part of it) that stretches or shrinks nicely + void DrawTextureTiled(Texture2D texture, Rectangle source, Rectangle dest, Vector2 origin, float rotation, float scale, Color tint); // Draw part of a texture (defined by a rectangle) with rotation and scale tiled into dest. + void DrawTexturePro(Texture2D texture, Rectangle source, Rectangle dest, Vector2 origin, float rotation, Color tint); // Draw a part of a texture defined by a rectangle with 'pro' parameters + void DrawTextureNPatch(Texture2D texture, NPatchInfo nPatchInfo, Rectangle dest, Vector2 origin, float rotation, Color tint); // Draws a texture (or part of it) that stretches or shrinks nicely + + // Color/pixel related functions + Color Fade(Color color, float alpha); // Returns color with alpha applied, alpha goes from 0.0f to 1.0f + int ColorToInt(Color color); // Returns hexadecimal value for a Color + Vector4 ColorNormalize(Color color); // Returns Color normalized as float [0..1] + Color ColorFromNormalized(Vector4 normalized); // Returns Color from normalized values [0..1] + Vector3 ColorToHSV(Color color); // Returns HSV values for a Color + Color ColorFromHSV(float hue, float saturation, float value); // Returns a Color from HSV values + Color ColorAlpha(Color color, float alpha); // Returns color with alpha applied, alpha goes from 0.0f to 1.0f + Color ColorAlphaBlend(Color dst, Color src, Color tint); // Returns src alpha-blended into dst color with tint + Color GetColor(int hexValue); // Get Color structure from hexadecimal value + Color GetPixelColor(void *srcPtr, int format); // Get Color from a source pixel pointer of certain format + void SetPixelColor(void *dstPtr, Color color, int format); // Set color formatted into destination pixel pointer + int GetPixelDataSize(int width, int height, int format); // Get pixel data size in bytes for certain format - // Image/Texture misc functions - int GetPixelDataSize(int width, int height, int format); // Get pixel data size in bytes (image or texture) -
\ No newline at end of file |
