Use vectors for pairs of scalar parameters

This commit is contained in:
Chris Thrasher committed 2024-08-31 12:03:21 -06:00
1 parent 10685c7d0d
commit 86d52f4712
20 files changed
+101 -123

No files matched your search

+16 -22
View File
@@ -42,25 +42,23 @@
///
/// This image is filled with black pixels.
///
/// \param width Width of the image
/// \param height Height of the image
/// \param size Size of the image
///
/// \return A new sfImage object
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfImage* sfImage_create(unsigned int width, unsigned int height);
CSFML_GRAPHICS_API sfImage* sfImage_create(sfVector2u size);
////////////////////////////////////////////////////////////
/// \brief Create an image and fill it with a unique color
///
/// \param width Width of the image
/// \param height Height of the image
/// \param color Fill color
/// \param size Size of the image
/// \param color Fill color
///
/// \return A new sfImage object
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfImage* sfImage_createFromColor(unsigned int width, unsigned int height, sfColor color);
CSFML_GRAPHICS_API sfImage* sfImage_createFromColor(sfVector2u size, sfColor color);
////////////////////////////////////////////////////////////
/// \brief Create an image from an array of pixels
@@ -70,14 +68,13 @@ CSFML_GRAPHICS_API sfImage* sfImage_createFromColor(unsigned int width, unsigned
/// an undefined behaviour.
/// If \a pixels is null, an empty image is created.
///
/// \param width Width of the image
/// \param height Height of the image
/// \param size Size of the image
/// \param pixels Array of pixels to copy to the image
///
/// \return A new sfImage object
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfImage* sfImage_createFromPixels(unsigned int width, unsigned int height, const uint8_t* pixels);
CSFML_GRAPHICS_API sfImage* sfImage_createFromPixels(sfVector2u size, const uint8_t* pixels);
////////////////////////////////////////////////////////////
/// \brief Create an image from a file on disk
@@ -219,15 +216,14 @@ CSFML_GRAPHICS_API void sfImage_createMaskFromColor(sfImage* image, sfColor colo
///
/// \param image Image object
/// \param source Source image to copy
/// \param destX X coordinate of the destination position
/// \param destY Y coordinate of the destination position
/// \param dest Coordinates of the destination position
/// \param sourceRect Sub-rectangle of the source image to copy
/// \param applyAlpha Should the copy take in account the source transparency?
///
/// \return True if the operation was successful, false otherwise
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API bool sfImage_copyImage(sfImage* image, const sfImage* source, unsigned int destX, unsigned int destY, sfIntRect sourceRect, bool applyAlpha);
CSFML_GRAPHICS_API bool sfImage_copyImage(sfImage* image, const sfImage* source, sfVector2u dest, sfIntRect sourceRect, bool applyAlpha);
////////////////////////////////////////////////////////////
/// \brief Change the color of a pixel in an image
@@ -236,13 +232,12 @@ CSFML_GRAPHICS_API bool sfImage_copyImage(sfImage* image, const sfImage* source,
/// coordinates, using out-of-range values will result in
/// an undefined behaviour.
///
/// \param image Image object
/// \param x X coordinate of pixel to change
/// \param y Y coordinate of pixel to change
/// \param color New color of the pixel
/// \param image Image object
/// \param coords Coordinates of pixel to change
/// \param color New color of the pixel
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfImage_setPixel(sfImage* image, unsigned int x, unsigned int y, sfColor color);
CSFML_GRAPHICS_API void sfImage_setPixel(sfImage* image, sfVector2u coords, sfColor color);
////////////////////////////////////////////////////////////
/// \brief Get the color of a pixel in an image
@@ -251,14 +246,13 @@ CSFML_GRAPHICS_API void sfImage_setPixel(sfImage* image, unsigned int x, unsigne
/// coordinates, using out-of-range values will result in
/// an undefined behaviour.
///
/// \param image Image object
/// \param x X coordinate of pixel to get
/// \param y Y coordinate of pixel to get
/// \param image Image object
/// \param coords Coordinates of pixel to get
///
/// \return Color of the pixel at coordinates (x, y)
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfColor sfImage_getPixel(const sfImage* image, unsigned int x, unsigned int y);
CSFML_GRAPHICS_API sfColor sfImage_getPixel(const sfImage* image, sfVector2u coords);
////////////////////////////////////////////////////////////
/// \brief Get a read-only pointer to the array of pixels of an image
+4 -5
View File
@@ -51,15 +51,14 @@ typedef struct
////////////////////////////////////////////////////////////
/// \brief Check if a point is inside a rectangle's area
///
/// \param rect Rectangle to test
/// \param x X coordinate of the point to test
/// \param y Y coordinate of the point to test
/// \param rect Rectangle to test
/// \param point Coordinates of the point to test
///
/// \return true if the point is inside
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API bool sfFloatRect_contains(const sfFloatRect* rect, float x, float y);
CSFML_GRAPHICS_API bool sfIntRect_contains(const sfIntRect* rect, int x, int y);
CSFML_GRAPHICS_API bool sfFloatRect_contains(const sfFloatRect* rect, sfVector2f point);
CSFML_GRAPHICS_API bool sfIntRect_contains(const sfIntRect* rect, sfVector2i point);
////////////////////////////////////////////////////////////
/// \brief Check intersection between two rectangles
+2 -3
View File
@@ -42,14 +42,13 @@
////////////////////////////////////////////////////////////
/// \brief Construct a new render texture
///
/// \param width Width of the render texture
/// \param height Height of the render texture
/// \param size Size of the render texture
/// \param settings Settings of the render texture
///
/// \return A new sfRenderTexture object, or NULL if it failed
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfRenderTexture* sfRenderTexture_create(unsigned int width, unsigned int height, const sfContextSettings* settings);
CSFML_GRAPHICS_API sfRenderTexture* sfRenderTexture_create(sfVector2u size, const sfContextSettings* settings);
////////////////////////////////////////////////////////////
/// \brief Destroy an existing render texture
+2 -3
View File
@@ -201,12 +201,11 @@ CSFML_GRAPHICS_API void sfRenderWindow_setUnicodeTitle(sfRenderWindow* renderWin
/// \brief Change a render window's icon
///
/// \param renderWindow Render window object
/// \param width Icon's width, in pixels
/// \param height Icon's height, in pixels
/// \param size Icon's size, in pixels
/// \param pixels Pointer to the pixels in memory, format must be RGBA 32 bits
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfRenderWindow_setIcon(sfRenderWindow* renderWindow, unsigned int width, unsigned int height, const uint8_t* pixels);
CSFML_GRAPHICS_API void sfRenderWindow_setIcon(sfRenderWindow* renderWindow, sfVector2u size, const uint8_t* pixels);
////////////////////////////////////////////////////////////
/// \brief Show or hide a render window
+13 -20
View File
@@ -48,13 +48,12 @@ typedef enum
////////////////////////////////////////////////////////////
/// \brief Create a new texture
///
/// \param width Texture width
/// \param height Texture height
/// \param size Texture size
///
/// \return A new sfTexture object, or NULL if it failed
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfTexture* sfTexture_create(unsigned int width, unsigned int height);
CSFML_GRAPHICS_API sfTexture* sfTexture_create(sfVector2u size);
////////////////////////////////////////////////////////////
/// \brief Create a new texture from a file
@@ -201,13 +200,11 @@ CSFML_GRAPHICS_API sfImage* sfTexture_copyToImage(const sfTexture* texture);
///
/// \param texture Texture to update
/// \param pixels Array of pixels to copy to the texture
/// \param width Width of the pixel region contained in \a pixels
/// \param height Height of the pixel region contained in \a pixels
/// \param x X offset in the texture where to copy the source pixels
/// \param y Y offset in the texture where to copy the source pixels
/// \param size size of the pixel region contained in \a pixels
/// \param offset Offset in the texture where to copy the source pixels
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfTexture_updateFromPixels(sfTexture* texture, const uint8_t* pixels, unsigned int width, unsigned int height, unsigned int x, unsigned int y);
CSFML_GRAPHICS_API void sfTexture_updateFromPixels(sfTexture* texture, const uint8_t* pixels, sfVector2u size, sfVector2u offset);
////////////////////////////////////////////////////////////
/// \brief Update a part of this texture from another texture
@@ -221,44 +218,40 @@ CSFML_GRAPHICS_API void sfTexture_updateFromPixels(sfTexture* texture, const uin
///
/// \param destination Destination texture to copy source texture to
/// \param source Source texture to copy to destination texture
/// \param x X offset in this texture where to copy the source texture
/// \param y Y offset in this texture where to copy the source texture
/// \param offset Offset in this texture where to copy the source texture
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfTexture_updateFromTexture(sfTexture* destination, const sfTexture* source, unsigned int x, unsigned int y);
CSFML_GRAPHICS_API void sfTexture_updateFromTexture(sfTexture* destination, const sfTexture* source, sfVector2u offset);
////////////////////////////////////////////////////////////
/// \brief Update a texture from an image
///
/// \param texture Texture to update
/// \param image Image to copy to the texture
/// \param x X offset in the texture where to copy the source pixels
/// \param y Y offset in the texture where to copy the source pixels
/// \param offset Offset in the texture where to copy the source pixels
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfTexture_updateFromImage(sfTexture* texture, const sfImage* image, unsigned int x, unsigned int y);
CSFML_GRAPHICS_API void sfTexture_updateFromImage(sfTexture* texture, const sfImage* image, sfVector2u offset);
////////////////////////////////////////////////////////////
/// \brief Update a texture from the contents of a window
///
/// \param texture Texture to update
/// \param window Window to copy to the texture
/// \param x X offset in the texture where to copy the source pixels
/// \param y Y offset in the texture where to copy the source pixels
/// \param offset Offset in the texture where to copy the source pixels
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfTexture_updateFromWindow(sfTexture* texture, const sfWindow* window, unsigned int x, unsigned int y);
CSFML_GRAPHICS_API void sfTexture_updateFromWindow(sfTexture* texture, const sfWindow* window, sfVector2u offset);
////////////////////////////////////////////////////////////
/// \brief Update a texture from the contents of a render-window
///
/// \param texture Texture to update
/// \param renderWindow Render-window to copy to the texture
/// \param x X offset in the texture where to copy the source pixels
/// \param y Y offset in the texture where to copy the source pixels
/// \param offset Offset in the texture where to copy the source pixels
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfTexture_updateFromRenderWindow(sfTexture* texture, const sfRenderWindow* renderWindow, unsigned int x, unsigned int y);
CSFML_GRAPHICS_API void sfTexture_updateFromRenderWindow(sfTexture* texture, const sfRenderWindow* renderWindow, sfVector2u offset);
////////////////////////////////////////////////////////////
/// \brief Enable or disable the smooth filter on a texture
+9 -14
View File
@@ -147,11 +147,10 @@ CSFML_GRAPHICS_API void sfTransform_combine(sfTransform* transform, const sfTran
/// \brief Combine a transform with a translation
///
/// \param transform Transform object
/// \param x Offset to apply on X axis
/// \param y Offset to apply on Y axis
/// \param offset Offset to apply
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfTransform_translate(sfTransform* transform, float x, float y);
CSFML_GRAPHICS_API void sfTransform_translate(sfTransform* transform, sfVector2f offset);
////////////////////////////////////////////////////////////
/// \brief Combine the current transform with a rotation
@@ -172,21 +171,19 @@ CSFML_GRAPHICS_API void sfTransform_rotate(sfTransform* transform, float angle);
///
/// \param transform Transform object
/// \param angle Rotation angle, in degrees
/// \param centerX X coordinate of the center of rotation
/// \param centerY Y coordinate of the center of rotation
/// \param center Coordinates of the center of rotation
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfTransform_rotateWithCenter(sfTransform* transform, float angle, float centerX, float centerY);
CSFML_GRAPHICS_API void sfTransform_rotateWithCenter(sfTransform* transform, float angle, sfVector2f center);
////////////////////////////////////////////////////////////
/// \brief Combine the current transform with a scaling
///
/// \param transform Transform object
/// \param scaleX Scaling factor on the X axis
/// \param scaleY Scaling factor on the Y axis
/// \param scale Scaling factor
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfTransform_scale(sfTransform* transform, float scaleX, float scaleY);
CSFML_GRAPHICS_API void sfTransform_scale(sfTransform* transform, sfVector2f scale);
////////////////////////////////////////////////////////////
/// \brief Combine the current transform with a scaling
@@ -197,13 +194,11 @@ CSFML_GRAPHICS_API void sfTransform_scale(sfTransform* transform, float scaleX,
/// [translate(-center), scale(factors), translate(center)]
///
/// \param transform Transform object
/// \param scaleX Scaling factor on X axis
/// \param scaleY Scaling factor on Y axis
/// \param centerX X coordinate of the center of scaling
/// \param centerY Y coordinate of the center of scaling
/// \param scale Scaling factor
/// \param center Coordinates of the center of scaling
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfTransform_scaleWithCenter(sfTransform* transform, float scaleX, float scaleY, float centerX, float centerY);
CSFML_GRAPHICS_API void sfTransform_scaleWithCenter(sfTransform* transform, sfVector2f scale, sfVector2f center);
////////////////////////////////////////////////////////////
/// \brief Compare two transforms for equality
+2 -2
View File
@@ -28,6 +28,7 @@
// Headers
////////////////////////////////////////////////////////////
#include <CSFML/Window/Export.h>
#include <CSFML/System/Vector2.h>
#include <stddef.h>
@@ -39,8 +40,7 @@
////////////////////////////////////////////////////////////
typedef struct
{
unsigned int width; ///< Video mode width, in pixels
unsigned int height; ///< Video mode height, in pixels
sfVector2u size; ///< Video mode size, in pixels
unsigned int bitsPerPixel; ///< Video mode pixel depth, in bits per pixels
} sfVideoMode;
+2 -3
View File
@@ -287,12 +287,11 @@ CSFML_WINDOW_API void sfWindow_setUnicodeTitle(sfWindow* window, const sfChar32*
/// in 32-bits RGBA format.
///
/// \param window Window object
/// \param width Icon's width, in pixels
/// \param height Icon's height, in pixels
/// \param size Icon's size, in pixels
/// \param pixels Pointer to the array of pixels in memory
///
////////////////////////////////////////////////////////////
CSFML_WINDOW_API void sfWindow_setIcon(sfWindow* window, unsigned int width, unsigned int height, const uint8_t* pixels);
CSFML_WINDOW_API void sfWindow_setIcon(sfWindow* window, sfVector2u size, const uint8_t* pixels);
////////////////////////////////////////////////////////////
/// \brief Show or hide a window
+2 -3
View File
@@ -250,12 +250,11 @@ CSFML_WINDOW_API void sfWindowBase_setUnicodeTitle(sfWindowBase* windowBase, con
/// in 32-bits RGBA format.
///
/// \param windowBase Window object
/// \param width Icon's width, in pixels
/// \param height Icon's height, in pixels
/// \param size Icon's size, in pixels
/// \param pixels Pointer to the array of pixels in memory
///
////////////////////////////////////////////////////////////
CSFML_WINDOW_API void sfWindowBase_setIcon(sfWindowBase* windowBase, unsigned int width, unsigned int height, const uint8_t* pixels);
CSFML_WINDOW_API void sfWindowBase_setIcon(sfWindowBase* windowBase, sfVector2u size, const uint8_t* pixels);
////////////////////////////////////////////////////////////
/// \brief Show or hide a window