mirror of
https://github.com/SFML/CSFML.git
synced 2026-10-26 13:06:13 +01:00
Updated comments of graphics classes
This commit is contained in:
1 parent
44670984af
commit
44d4c4e707
9 files changed
+349
-375
No files matched your search
@@ -31,20 +31,17 @@
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Define some common colors
|
||||
////////////////////////////////////////////////////////////
|
||||
sfColor sfBlack = sfColor_FromRGB( 0, 0, 0);
|
||||
sfColor sfWhite = sfColor_FromRGB(255, 255, 255);
|
||||
sfColor sfRed = sfColor_FromRGB(255, 0, 0);
|
||||
sfColor sfGreen = sfColor_FromRGB( 0, 255, 0);
|
||||
sfColor sfBlue = sfColor_FromRGB( 0, 0, 255);
|
||||
sfColor sfYellow = sfColor_FromRGB(255, 255, 0);
|
||||
sfColor sfMagenta = sfColor_FromRGB(255, 0, 255);
|
||||
sfColor sfCyan = sfColor_FromRGB( 0, 255, 255);
|
||||
sfColor sfBlack = sfColor_FromRGB( 0, 0, 0);
|
||||
sfColor sfWhite = sfColor_FromRGB(255, 255, 255);
|
||||
sfColor sfRed = sfColor_FromRGB(255, 0, 0);
|
||||
sfColor sfGreen = sfColor_FromRGB( 0, 255, 0);
|
||||
sfColor sfBlue = sfColor_FromRGB( 0, 0, 255);
|
||||
sfColor sfYellow = sfColor_FromRGB(255, 255, 0);
|
||||
sfColor sfMagenta = sfColor_FromRGB(255, 0, 255);
|
||||
sfColor sfCyan = sfColor_FromRGB( 0, 255, 255);
|
||||
sfColor sfTransparent = sfColor_FromRGBA( 0, 0, 0, 0);
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Construct a color from its 3 RGB components
|
||||
////////////////////////////////////////////////////////////
|
||||
sfColor sfColor_FromRGB(sfUint8 red, sfUint8 green, sfUint8 blue)
|
||||
{
|
||||
@@ -52,8 +49,6 @@ sfColor sfColor_FromRGB(sfUint8 red, sfUint8 green, sfUint8 blue)
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Construct a color from its 4 RGBA components
|
||||
////////////////////////////////////////////////////////////
|
||||
sfColor sfColor_FromRGBA(sfUint8 red, sfUint8 green, sfUint8 blue, sfUint8 alpha)
|
||||
{
|
||||
@@ -68,8 +63,6 @@ sfColor sfColor_FromRGBA(sfUint8 red, sfUint8 green, sfUint8 blue, sfUint8 alpha
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Add two colors
|
||||
////////////////////////////////////////////////////////////
|
||||
sfColor sfColor_Add(sfColor color1, sfColor color2)
|
||||
{
|
||||
@@ -85,8 +78,6 @@ sfColor sfColor_Add(sfColor color1, sfColor color2)
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Modulate two colors
|
||||
////////////////////////////////////////////////////////////
|
||||
sfColor sfColor_Modulate(sfColor color1, sfColor color2)
|
||||
{
|
||||
|
||||
+15
-47
@@ -30,9 +30,16 @@
|
||||
#include <SFML/Internal.h>
|
||||
#include <SFML/CallbackStream.h>
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Create a new image filled with a color
|
||||
sfImage* sfImage_Create(unsigned int width, unsigned int height)
|
||||
{
|
||||
sfImage* image = new sfImage;
|
||||
image->This.Create(width, height);
|
||||
|
||||
return image;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
sfImage* sfImage_CreateFromColor(unsigned int width, unsigned int height, sfColor color)
|
||||
{
|
||||
@@ -43,8 +50,6 @@ sfImage* sfImage_CreateFromColor(unsigned int width, unsigned int height, sfColo
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Create a new image from an array of pixels in memory
|
||||
////////////////////////////////////////////////////////////
|
||||
sfImage* sfImage_CreateFromPixels(unsigned int width, unsigned int height, const sfUint8* data)
|
||||
{
|
||||
@@ -55,8 +60,6 @@ sfImage* sfImage_CreateFromPixels(unsigned int width, unsigned int height, const
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Create a new image from a file
|
||||
////////////////////////////////////////////////////////////
|
||||
sfImage* sfImage_CreateFromFile(const char* filename)
|
||||
{
|
||||
@@ -72,8 +75,6 @@ sfImage* sfImage_CreateFromFile(const char* filename)
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Create a new image from a file in memory
|
||||
////////////////////////////////////////////////////////////
|
||||
sfImage* sfImage_CreateFromMemory(const void* data, size_t sizeInBytes)
|
||||
{
|
||||
@@ -89,8 +90,6 @@ sfImage* sfImage_CreateFromMemory(const void* data, size_t sizeInBytes)
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Create a new image from a custom stream
|
||||
////////////////////////////////////////////////////////////
|
||||
sfImage* sfImage_CreateFromStream(sfInputStream* stream)
|
||||
{
|
||||
@@ -109,8 +108,6 @@ sfImage* sfImage_CreateFromStream(sfInputStream* stream)
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Copy an existing image
|
||||
////////////////////////////////////////////////////////////
|
||||
sfImage* sfImage_Copy(sfImage* image)
|
||||
{
|
||||
@@ -120,8 +117,6 @@ sfImage* sfImage_Copy(sfImage* image)
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Destroy an existing image
|
||||
////////////////////////////////////////////////////////////
|
||||
void sfImage_Destroy(sfImage* image)
|
||||
{
|
||||
@@ -129,8 +124,6 @@ void sfImage_Destroy(sfImage* image)
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Save the content of an image to a file
|
||||
////////////////////////////////////////////////////////////
|
||||
sfBool sfImage_SaveToFile(const sfImage* image, const char* filename)
|
||||
{
|
||||
@@ -138,58 +131,41 @@ sfBool sfImage_SaveToFile(const sfImage* image, const char* filename)
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Create a transparency mask for an image from a specified colorkey
|
||||
////////////////////////////////////////////////////////////
|
||||
void sfImage_CreateMaskFromColor(sfImage* image, sfColor colorKey, sfUint8 alpha)
|
||||
{
|
||||
sf::Color SFMLColor(colorKey.r, colorKey.g, colorKey.b, colorKey.a);
|
||||
CSFML_CALL(image, CreateMaskFromColor(SFMLColor, alpha));
|
||||
CSFML_CALL(image, CreateMaskFromColor(sf::Color(colorKey.r, colorKey.g, colorKey.b, colorKey.a), alpha));
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Copy pixels from another image onto this one.
|
||||
/// This function does a slow pixel copy and should only
|
||||
/// be used at initialization time
|
||||
////////////////////////////////////////////////////////////
|
||||
void sfImage_CopyImage(sfImage* image, const sfImage* source, unsigned int destX, unsigned int destY, sfIntRect sourceRect, sfBool applyAlpha)
|
||||
{
|
||||
CSFML_CHECK(source);
|
||||
sf::IntRect SFMLRect(sourceRect.Left, sourceRect.Top, sourceRect.Width, sourceRect.Height);
|
||||
CSFML_CALL(image, Copy(source->This, destX, destY, SFMLRect, applyAlpha == sfTrue));
|
||||
sf::IntRect sfmlRect(sourceRect.Left, sourceRect.Top, sourceRect.Width, sourceRect.Height);
|
||||
CSFML_CALL(image, Copy(source->This, destX, destY, sfmlRect, applyAlpha == sfTrue));
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Change the color of a pixel of an image
|
||||
/// Don't forget to call Update when you end modifying pixels
|
||||
////////////////////////////////////////////////////////////
|
||||
void sfImage_SetPixel(sfImage* image, unsigned int x, unsigned int y, sfColor color)
|
||||
{
|
||||
sf::Color SFMLColor(color.r, color.g, color.b, color.a);
|
||||
CSFML_CALL(image, SetPixel(x, y, SFMLColor));
|
||||
CSFML_CALL(image, SetPixel(x, y, sf::Color(color.r, color.g, color.b, color.a)));
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Get a pixel from an image
|
||||
////////////////////////////////////////////////////////////
|
||||
sfColor sfImage_GetPixel(const sfImage* image, unsigned int x, unsigned int y)
|
||||
{
|
||||
sfColor color = {0, 0, 0, 0};
|
||||
CSFML_CHECK_RETURN(image, color);
|
||||
|
||||
sf::Color SFMLColor = image->This.GetPixel(x, y);
|
||||
sf::Color sfmlColor = image->This.GetPixel(x, y);
|
||||
|
||||
return sfColor_FromRGBA(SFMLColor.r, SFMLColor.g, SFMLColor.b, SFMLColor.a);
|
||||
return sfColor_FromRGBA(sfmlColor.r, sfmlColor.g, sfmlColor.b, sfmlColor.a);
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Get a read-only pointer to the array of pixels of an image (8 bits integers RGBA)
|
||||
/// Array size is sfImage_GetWidth() x sfImage_GetHeight() x 4
|
||||
/// This pointer becomes invalid if you reload or resize the image
|
||||
////////////////////////////////////////////////////////////
|
||||
const sfUint8* sfImage_GetPixelsPtr(const sfImage* image)
|
||||
{
|
||||
@@ -197,8 +173,6 @@ const sfUint8* sfImage_GetPixelsPtr(const sfImage* image)
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Return the width of the image
|
||||
////////////////////////////////////////////////////////////
|
||||
unsigned int sfImage_GetWidth(const sfImage* image)
|
||||
{
|
||||
@@ -206,8 +180,6 @@ unsigned int sfImage_GetWidth(const sfImage* image)
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Return the height of the image
|
||||
////////////////////////////////////////////////////////////
|
||||
unsigned int sfImage_GetHeight(const sfImage* image)
|
||||
{
|
||||
@@ -215,8 +187,6 @@ unsigned int sfImage_GetHeight(const sfImage* image)
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Flip an image horizontally (left <-> right)
|
||||
////////////////////////////////////////////////////////////
|
||||
void sfImage_FlipHorizontally(sfImage* image)
|
||||
{
|
||||
@@ -224,8 +194,6 @@ void sfImage_FlipHorizontally(sfImage* image)
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Flip an image vertically (top <-> bottom)
|
||||
////////////////////////////////////////////////////////////
|
||||
void sfImage_FlipVertically(sfImage* image)
|
||||
{
|
||||
|
||||
+14
-61
@@ -30,8 +30,6 @@
|
||||
#include <SFML/Internal.h>
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Construct a default view (1000x1000)
|
||||
////////////////////////////////////////////////////////////
|
||||
sfView* sfView_Create(void)
|
||||
{
|
||||
@@ -39,8 +37,6 @@ sfView* sfView_Create(void)
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Construct a view from a rectangle
|
||||
////////////////////////////////////////////////////////////
|
||||
sfView* sfView_CreateFromRect(sfFloatRect rectangle)
|
||||
{
|
||||
@@ -51,8 +47,6 @@ sfView* sfView_CreateFromRect(sfFloatRect rectangle)
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Copy an existing view
|
||||
////////////////////////////////////////////////////////////
|
||||
sfView* sfView_Copy(sfView* view)
|
||||
{
|
||||
@@ -62,8 +56,6 @@ sfView* sfView_Copy(sfView* view)
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Destroy an existing view
|
||||
////////////////////////////////////////////////////////////
|
||||
void sfView_Destroy(sfView* view)
|
||||
{
|
||||
@@ -71,8 +63,6 @@ void sfView_Destroy(sfView* view)
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Change the center of a view
|
||||
////////////////////////////////////////////////////////////
|
||||
void sfView_SetCenter(sfView* view, float x, float y)
|
||||
{
|
||||
@@ -80,8 +70,6 @@ void sfView_SetCenter(sfView* view, float x, float y)
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Change the size of a view
|
||||
////////////////////////////////////////////////////////////
|
||||
void sfView_SetSize(sfView* view, float width, float height)
|
||||
{
|
||||
@@ -89,8 +77,6 @@ void sfView_SetSize(sfView* view, float width, float height)
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Set the angle of rotation of a view
|
||||
////////////////////////////////////////////////////////////
|
||||
void sfView_SetRotation(sfView* view, float angle)
|
||||
{
|
||||
@@ -98,8 +84,6 @@ void sfView_SetRotation(sfView* view, float angle)
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Set the target viewport of a view
|
||||
////////////////////////////////////////////////////////////
|
||||
void sfView_SetViewport(sfView* view, sfFloatRect viewport)
|
||||
{
|
||||
@@ -107,9 +91,6 @@ void sfView_SetViewport(sfView* view, sfFloatRect viewport)
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Reset a view to the given rectangle.
|
||||
/// Note: this function resets the rotation angle to 0.
|
||||
////////////////////////////////////////////////////////////
|
||||
void sfView_Reset(sfView* view, sfFloatRect rectangle)
|
||||
{
|
||||
@@ -118,51 +99,31 @@ void sfView_Reset(sfView* view, sfFloatRect rectangle)
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Get the X coordinate of the center of a view
|
||||
////////////////////////////////////////////////////////////
|
||||
float sfView_GetCenterX(const sfView* view)
|
||||
void sfView_GetCenter(const sfView* view, float* x, float* y)
|
||||
{
|
||||
CSFML_CHECK_RETURN(view, 0.f);
|
||||
CSFML_CHECK(view);
|
||||
|
||||
return view->This.GetCenter().x;
|
||||
sf::Vector2f center = view->This.GetCenter();
|
||||
if (x)
|
||||
*x = center.x;
|
||||
if (y)
|
||||
*y = center.y;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Get the Y coordinate of the center of a view
|
||||
////////////////////////////////////////////////////////////
|
||||
float sfView_GetCenterY(const sfView* view)
|
||||
void sfView_GetSize(const sfView* view, float* width, float* height)
|
||||
{
|
||||
CSFML_CHECK_RETURN(view, 0.f);
|
||||
CSFML_CHECK(view);
|
||||
|
||||
return view->This.GetCenter().y;
|
||||
sf::Vector2f size = view->This.GetSize();
|
||||
if (width)
|
||||
*width = size.x;
|
||||
if (height)
|
||||
*height = size.y;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Get the width of the view
|
||||
////////////////////////////////////////////////////////////
|
||||
float sfView_GetWidth(const sfView* view)
|
||||
{
|
||||
CSFML_CHECK_RETURN(view, 0.f);
|
||||
|
||||
return view->This.GetSize().x;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Get the height of the view
|
||||
////////////////////////////////////////////////////////////
|
||||
float sfView_GetHeight(const sfView* view)
|
||||
{
|
||||
CSFML_CHECK_RETURN(view, 0.f);
|
||||
|
||||
return view->This.GetSize().y;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Get the current rotation of a view
|
||||
////////////////////////////////////////////////////////////
|
||||
float sfView_GetRotation(const sfView* view)
|
||||
{
|
||||
@@ -170,8 +131,6 @@ float sfView_GetRotation(const sfView* view)
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Get the target viewport of a view
|
||||
////////////////////////////////////////////////////////////
|
||||
sfFloatRect sfView_GetViewport(const sfView* view)
|
||||
{
|
||||
@@ -188,8 +147,6 @@ sfFloatRect sfView_GetViewport(const sfView* view)
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Move a view
|
||||
////////////////////////////////////////////////////////////
|
||||
void sfView_Move(sfView* view, float offsetX, float offsetY)
|
||||
{
|
||||
@@ -197,8 +154,6 @@ void sfView_Move(sfView* view, float offsetX, float offsetY)
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Rotate a view
|
||||
////////////////////////////////////////////////////////////
|
||||
void sfView_Rotate(sfView* view, float angle)
|
||||
{
|
||||
@@ -206,8 +161,6 @@ void sfView_Rotate(sfView* view, float angle)
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Resize a view rectangle to simulate a zoom / unzoom effect
|
||||
////////////////////////////////////////////////////////////
|
||||
void sfView_Zoom(sfView* view, float factor)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user