From fb91bf4c6d7fd4979854f090a9e915863456f9d2 Mon Sep 17 00:00:00 2001 From: LaurentGom Date: Fri, 9 Apr 2010 17:05:21 +0000 Subject: [PATCH] Applied the sf::Rect modifications in CSFML and SFML.Net git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1504 4e206d99-4929-0410-ac5d-dfc041789085 --- CSFML/include/SFML/Graphics/Rect.h | 20 +- CSFML/src/SFML/Graphics/Font.cpp | 8 +- CSFML/src/SFML/Graphics/Image.cpp | 6 +- CSFML/src/SFML/Graphics/Rect.cpp | 41 +--- CSFML/src/SFML/Graphics/RenderImage.cpp | 4 +- CSFML/src/SFML/Graphics/RenderWindow.cpp | 4 +- CSFML/src/SFML/Graphics/Sprite.cpp | 6 +- CSFML/src/SFML/Graphics/Text.cpp | 4 +- CSFML/src/SFML/Graphics/View.cpp | 8 +- CSFML/src/SFML/Graphics/csfml-graphics-d.def | 2 - CSFML/src/SFML/Graphics/csfml-graphics.def | 2 - dotnet/src/Graphics/Rect.cs | 187 +++++++------------ 12 files changed, 99 insertions(+), 193 deletions(-) diff --git a/CSFML/include/SFML/Graphics/Rect.h b/CSFML/include/SFML/Graphics/Rect.h index f6fe2a88..2fbc5769 100644 --- a/CSFML/include/SFML/Graphics/Rect.h +++ b/CSFML/include/SFML/Graphics/Rect.h @@ -39,30 +39,18 @@ typedef struct { float Left; float Top; - float Right; - float Bottom; + float Width; + float Height; } sfFloatRect; typedef struct { int Left; int Top; - int Right; - int Bottom; + int Width; + int Height; } sfIntRect; - -//////////////////////////////////////////////////////////// -/// Move a rectangle by the given offset -/// -/// \param rect : Rectangle to move -/// \param offsetX : Horizontal offset -/// \param offsetY : Vertical offset -/// -//////////////////////////////////////////////////////////// -CSFML_API void sfFloatRect_Offset(sfFloatRect* rect, float offsetX, float offsetY); -CSFML_API void sfIntRect_Offset(sfIntRect* rect, int offsetX, int offsetY); - //////////////////////////////////////////////////////////// /// Check if a point is inside a rectangle's area /// diff --git a/CSFML/src/SFML/Graphics/Font.cpp b/CSFML/src/SFML/Graphics/Font.cpp index 5787fd8b..27d21acd 100644 --- a/CSFML/src/SFML/Graphics/Font.cpp +++ b/CSFML/src/SFML/Graphics/Font.cpp @@ -95,12 +95,12 @@ sfGlyph sfFont_GetGlyph(sfFont* font, sfUint32 codePoint, unsigned int character glyph.Advance = SFMLGlyph.Advance; glyph.Bounds.Left = SFMLGlyph.Bounds.Left; glyph.Bounds.Top = SFMLGlyph.Bounds.Top; - glyph.Bounds.Right = SFMLGlyph.Bounds.Right; - glyph.Bounds.Bottom = SFMLGlyph.Bounds.Bottom; + glyph.Bounds.Width = SFMLGlyph.Bounds.Width; + glyph.Bounds.Height = SFMLGlyph.Bounds.Height; glyph.SubRect.Left = SFMLGlyph.SubRect.Left; glyph.SubRect.Top = SFMLGlyph.SubRect.Top; - glyph.SubRect.Right = SFMLGlyph.SubRect.Right; - glyph.SubRect.Bottom = SFMLGlyph.SubRect.Bottom; + glyph.SubRect.Width = SFMLGlyph.SubRect.Width; + glyph.SubRect.Height = SFMLGlyph.SubRect.Height; return glyph; } diff --git a/CSFML/src/SFML/Graphics/Image.cpp b/CSFML/src/SFML/Graphics/Image.cpp index c1eff4cd..7ba02cd5 100644 --- a/CSFML/src/SFML/Graphics/Image.cpp +++ b/CSFML/src/SFML/Graphics/Image.cpp @@ -155,7 +155,7 @@ void sfImage_CreateMaskFromColor(sfImage* image, sfColor colorKey, sfUint8 alpha void sfImage_CopyImage(sfImage* image, const sfImage* source, unsigned int destX, unsigned int destY, sfIntRect sourceRect) { CSFML_CHECK(source); - sf::IntRect SFMLRect(sourceRect.Left, sourceRect.Top, sourceRect.Right, sourceRect.Bottom); + sf::IntRect SFMLRect(sourceRect.Left, sourceRect.Top, sourceRect.Width, sourceRect.Height); CSFML_CALL_PTR(image, Copy(*source->This, destX, destY, SFMLRect)); } @@ -167,7 +167,7 @@ void sfImage_CopyImage(sfImage* image, const sfImage* source, unsigned int destX CSFML_API sfBool sfImage_CopyScreen(sfImage* image, sfRenderWindow* window, sfIntRect sourceRect) { CSFML_CHECK_RETURN(window, sfFalse); - sf::IntRect SFMLRect(sourceRect.Left, sourceRect.Top, sourceRect.Right, sourceRect.Bottom); + sf::IntRect SFMLRect(sourceRect.Left, sourceRect.Top, sourceRect.Width, sourceRect.Height); CSFML_CALL_PTR_RETURN(image, CopyScreen(window->This, SFMLRect), sfFalse); } @@ -213,7 +213,7 @@ const sfUint8* sfImage_GetPixelsPtr(const sfImage* image) //////////////////////////////////////////////////////////// void sfImage_UpdatePixels(const sfImage* image, const sfUint8* pixels, sfIntRect rectangle) { - sf::IntRect rect(rectangle.Left, rectangle.Top, rectangle.Right, rectangle.Bottom); + sf::IntRect rect(rectangle.Left, rectangle.Top, rectangle.Width, rectangle.Height); CSFML_CALL_PTR(image, UpdatePixels(pixels, rect)); } diff --git a/CSFML/src/SFML/Graphics/Rect.cpp b/CSFML/src/SFML/Graphics/Rect.cpp index fe011eea..4061315b 100644 --- a/CSFML/src/SFML/Graphics/Rect.cpp +++ b/CSFML/src/SFML/Graphics/Rect.cpp @@ -30,39 +30,18 @@ #include -//////////////////////////////////////////////////////////// -/// Move a rectangle by the given offset -//////////////////////////////////////////////////////////// -void sfFloatRect_Offset(sfFloatRect* rect, float offsetX, float offsetY) -{ - CSFML_CHECK(rect) - rect->Left += offsetX; - rect->Right += offsetX; - rect->Top += offsetY; - rect->Bottom += offsetY; -} -void sfIntRect_Offset(sfIntRect* rect, int offsetX, int offsetY) -{ - CSFML_CHECK(rect) - rect->Left += offsetX; - rect->Right += offsetX; - rect->Top += offsetY; - rect->Bottom += offsetY; -} - - //////////////////////////////////////////////////////////// /// Check if a point is inside a rectangle's area //////////////////////////////////////////////////////////// sfBool sfFloatRect_Contains(const sfFloatRect* rect, float x, float y) { CSFML_CHECK_RETURN(rect, sfFalse) - return sf::FloatRect(rect->Left, rect->Top, rect->Right, rect->Bottom).Contains(x, y); + return sf::FloatRect(rect->Left, rect->Top, rect->Width, rect->Height).Contains(x, y); } sfBool sfIntRect_Contains(const sfIntRect* rect, int x, int y) { CSFML_CHECK_RETURN(rect, sfFalse) - return sf::IntRect(rect->Left, rect->Top, rect->Right, rect->Bottom).Contains(x, y); + return sf::IntRect(rect->Left, rect->Top, rect->Width, rect->Height).Contains(x, y); } @@ -74,8 +53,8 @@ sfBool sfFloatRect_Intersects(const sfFloatRect* rect1, const sfFloatRect* rect2 CSFML_CHECK_RETURN(rect1, sfFalse) CSFML_CHECK_RETURN(rect2, sfFalse) - sf::FloatRect SFMLRect1(rect1->Left, rect1->Top, rect1->Right, rect1->Bottom); - sf::FloatRect SFMLRect2(rect2->Left, rect2->Top, rect2->Right, rect2->Bottom); + sf::FloatRect SFMLRect1(rect1->Left, rect1->Top, rect1->Width, rect1->Height); + sf::FloatRect SFMLRect2(rect2->Left, rect2->Top, rect2->Width, rect2->Height); if (intersection) { @@ -84,8 +63,8 @@ sfBool sfFloatRect_Intersects(const sfFloatRect* rect1, const sfFloatRect* rect2 intersection->Left = overlap.Left; intersection->Top = overlap.Top; - intersection->Right = overlap.Right; - intersection->Bottom = overlap.Bottom; + intersection->Width = overlap.Width; + intersection->Height = overlap.Height; return intersects; } @@ -99,8 +78,8 @@ sfBool sfIntRect_Intersects(const sfIntRect* rect1, const sfIntRect* rect2, sfIn CSFML_CHECK_RETURN(rect1, sfFalse) CSFML_CHECK_RETURN(rect2, sfFalse) - sf::IntRect SFMLRect1(rect1->Left, rect1->Top, rect1->Right, rect1->Bottom); - sf::IntRect SFMLRect2(rect2->Left, rect2->Top, rect2->Right, rect2->Bottom); + sf::IntRect SFMLRect1(rect1->Left, rect1->Top, rect1->Width, rect1->Height); + sf::IntRect SFMLRect2(rect2->Left, rect2->Top, rect2->Width, rect2->Height); if (intersection) { @@ -109,8 +88,8 @@ sfBool sfIntRect_Intersects(const sfIntRect* rect1, const sfIntRect* rect2, sfIn intersection->Left = overlap.Left; intersection->Top = overlap.Top; - intersection->Right = overlap.Right; - intersection->Bottom = overlap.Bottom; + intersection->Width = overlap.Width; + intersection->Height = overlap.Height; return intersects; } diff --git a/CSFML/src/SFML/Graphics/RenderImage.cpp b/CSFML/src/SFML/Graphics/RenderImage.cpp index c1ba674e..464a0e5c 100644 --- a/CSFML/src/SFML/Graphics/RenderImage.cpp +++ b/CSFML/src/SFML/Graphics/RenderImage.cpp @@ -212,8 +212,8 @@ sfIntRect sfRenderImage_GetViewport(const sfRenderImage* renderImage, const sfVi sf::IntRect SFMLrect = renderImage->This.GetViewport(view->This); rect.Left = SFMLrect.Left; rect.Top = SFMLrect.Top; - rect.Right = SFMLrect.Right; - rect.Bottom = SFMLrect.Bottom; + rect.Width = SFMLrect.Width; + rect.Height = SFMLrect.Height; return rect; } diff --git a/CSFML/src/SFML/Graphics/RenderWindow.cpp b/CSFML/src/SFML/Graphics/RenderWindow.cpp index 543e3a11..3348b08a 100644 --- a/CSFML/src/SFML/Graphics/RenderWindow.cpp +++ b/CSFML/src/SFML/Graphics/RenderWindow.cpp @@ -449,8 +449,8 @@ sfIntRect sfRenderWindow_GetViewport(const sfRenderWindow* renderWindow, const s sf::IntRect SFMLrect = renderWindow->This.GetViewport(view->This); rect.Left = SFMLrect.Left; rect.Top = SFMLrect.Top; - rect.Right = SFMLrect.Right; - rect.Bottom = SFMLrect.Bottom; + rect.Width = SFMLrect.Width; + rect.Height = SFMLrect.Height; return rect; } diff --git a/CSFML/src/SFML/Graphics/Sprite.cpp b/CSFML/src/SFML/Graphics/Sprite.cpp index 362f5f9d..791430f8 100644 --- a/CSFML/src/SFML/Graphics/Sprite.cpp +++ b/CSFML/src/SFML/Graphics/Sprite.cpp @@ -41,8 +41,8 @@ sfSprite* sfSprite_Create() sprite->Image = NULL; sprite->SubRect.Left = sprite->This.GetSubRect().Left; sprite->SubRect.Top = sprite->This.GetSubRect().Top; - sprite->SubRect.Right = sprite->This.GetSubRect().Right; - sprite->SubRect.Bottom = sprite->This.GetSubRect().Bottom; + sprite->SubRect.Width = sprite->This.GetSubRect().Width; + sprite->SubRect.Height = sprite->This.GetSubRect().Height; return sprite; } @@ -319,7 +319,7 @@ void sfSprite_SetImage(sfSprite* sprite, const sfImage* image, sfBool adjustToNe //////////////////////////////////////////////////////////// void sfSprite_SetSubRect(sfSprite* sprite, sfIntRect rectangle) { - CSFML_CALL(sprite, SetSubRect(sf::IntRect(rectangle.Left, rectangle.Top, rectangle.Right, rectangle.Bottom))) + CSFML_CALL(sprite, SetSubRect(sf::IntRect(rectangle.Left, rectangle.Top, rectangle.Width, rectangle.Height))) sprite->SubRect = rectangle; } diff --git a/CSFML/src/SFML/Graphics/Text.cpp b/CSFML/src/SFML/Graphics/Text.cpp index dd454d2d..1266fe50 100644 --- a/CSFML/src/SFML/Graphics/Text.cpp +++ b/CSFML/src/SFML/Graphics/Text.cpp @@ -425,8 +425,8 @@ sfFloatRect sfText_GetRect(const sfText* text) sf::FloatRect SFMLRect = text->This.GetRect(); text->Rect.Left = SFMLRect.Left; text->Rect.Top = SFMLRect.Top; - text->Rect.Right = SFMLRect.Right; - text->Rect.Bottom = SFMLRect.Bottom; + text->Rect.Width = SFMLRect.Width; + text->Rect.Height = SFMLRect.Height; return text->Rect; } diff --git a/CSFML/src/SFML/Graphics/View.cpp b/CSFML/src/SFML/Graphics/View.cpp index 94280a79..6b64adc4 100644 --- a/CSFML/src/SFML/Graphics/View.cpp +++ b/CSFML/src/SFML/Graphics/View.cpp @@ -103,7 +103,7 @@ void sfView_SetRotation(sfView* view, float angle) //////////////////////////////////////////////////////////// void sfView_SetViewport(sfView* view, sfFloatRect viewport) { - CSFML_CALL(view, SetViewport(sf::FloatRect(viewport.Left, viewport.Top, viewport.Right, viewport.Bottom))); + CSFML_CALL(view, SetViewport(sf::FloatRect(viewport.Left, viewport.Top, viewport.Width, viewport.Height))); } @@ -113,7 +113,7 @@ void sfView_SetViewport(sfView* view, sfFloatRect viewport) //////////////////////////////////////////////////////////// void sfView_Reset(sfView* view, sfFloatRect rectangle) { - CSFML_CALL(view, Reset(sf::FloatRect(rectangle.Left, rectangle.Top, rectangle.Right, rectangle.Bottom))); + CSFML_CALL(view, Reset(sf::FloatRect(rectangle.Left, rectangle.Top, rectangle.Width, rectangle.Height))); } @@ -181,8 +181,8 @@ sfFloatRect sfView_GetViewport(const sfView* view) sf::FloatRect SFMLRect = view->This.GetViewport(); rect.Left = SFMLRect.Left; rect.Top = SFMLRect.Top; - rect.Right = SFMLRect.Right; - rect.Bottom = SFMLRect.Bottom; + rect.Width = SFMLRect.Width; + rect.Height = SFMLRect.Height; return rect; } diff --git a/CSFML/src/SFML/Graphics/csfml-graphics-d.def b/CSFML/src/SFML/Graphics/csfml-graphics-d.def index 64461eb5..f9690ad5 100644 --- a/CSFML/src/SFML/Graphics/csfml-graphics-d.def +++ b/CSFML/src/SFML/Graphics/csfml-graphics-d.def @@ -32,10 +32,8 @@ EXPORTS sfImage_GetWidth sfImage_GetHeight sfImage_IsSmooth - sfFloatRect_Offset sfFloatRect_Contains sfFloatRect_Intersects - sfIntRect_Offset sfIntRect_Contains sfIntRect_Intersects sfShader_CreateFromFile diff --git a/CSFML/src/SFML/Graphics/csfml-graphics.def b/CSFML/src/SFML/Graphics/csfml-graphics.def index 0d262e3a..eda23e97 100644 --- a/CSFML/src/SFML/Graphics/csfml-graphics.def +++ b/CSFML/src/SFML/Graphics/csfml-graphics.def @@ -32,10 +32,8 @@ EXPORTS sfImage_GetWidth sfImage_GetHeight sfImage_IsSmooth - sfFloatRect_Offset sfFloatRect_Contains sfFloatRect_Intersects - sfIntRect_Offset sfIntRect_Contains sfIntRect_Intersects sfShader_CreateFromFile diff --git a/dotnet/src/Graphics/Rect.cs b/dotnet/src/Graphics/Rect.cs index 34ea15c2..41d05c88 100644 --- a/dotnet/src/Graphics/Rect.cs +++ b/dotnet/src/Graphics/Rect.cs @@ -20,50 +20,15 @@ namespace SFML /// /// Left coordinate of the rectangle /// Top coordinate of the rectangle - /// Right coordinate of the rectangle - /// Bottom coordinate of the rectangle + /// Width of the rectangle + /// Height of the rectangle //////////////////////////////////////////////////////////// - public IntRect(int left, int top, int right, int bottom) + public IntRect(int left, int top, int width, int height) { Left = left; Top = top; - Right = right; - Bottom = bottom; - } - - //////////////////////////////////////////////////////////// - /// - /// Width of the rectangle - /// - //////////////////////////////////////////////////////////// - public int Width - { - get {return Right - Left;} - } - - //////////////////////////////////////////////////////////// - /// - /// Height of the rectangle - /// - //////////////////////////////////////////////////////////// - public int Height - { - get {return Bottom - Top;} - } - - //////////////////////////////////////////////////////////// - /// - /// Move the whole rectangle by the given offset - /// - /// Horizontal offset - /// Vertical offset - //////////////////////////////////////////////////////////// - public void Offset(int offsetX, int offsetY) - { - Left += offsetX; - Top += offsetY; - Right += offsetX; - Bottom += offsetY; + Width = width; + Height = height; } //////////////////////////////////////////////////////////// @@ -76,7 +41,7 @@ namespace SFML //////////////////////////////////////////////////////////// public bool Contains(int x, int y) { - return (x >= Left) && (x <= Right) && (y >= Top) && (y <= Bottom); + return (x >= Left) && (x < Left + Width) && (y >= Top) && (y < Top + Height); } //////////////////////////////////////////////////////////// @@ -88,8 +53,13 @@ namespace SFML //////////////////////////////////////////////////////////// public bool Intersects(IntRect rect) { - return ((Math.Max(Left, rect.Left) < Math.Min(Right, rect.Right)) && - (Math.Max(Top, rect.Top) < Math.Min(Bottom, rect.Bottom))); + // Compute the intersection boundaries + int left = Math.Max(Left, rect.Left); + int top = Math.Max(Top, rect.Top); + int right = Math.Min(Left + Width, rect.Left + rect.Width); + int bottom = Math.Min(Top + Height, rect.Top + rect.Height); + + return (left < right) && (top < bottom); } //////////////////////////////////////////////////////////// @@ -102,25 +72,27 @@ namespace SFML //////////////////////////////////////////////////////////// public bool Intersects(IntRect rect, out IntRect overlap) { - IntRect Overlapping = new IntRect(Math.Max(Left, rect.Left), - Math.Max(Top, rect.Top), - Math.Min(Right, rect.Right), - Math.Min(Bottom, rect.Bottom)); + // Compute the intersection boundaries + int left = Math.Max(Left, rect.Left); + int top = Math.Max(Top, rect.Top); + int right = Math.Min(Left + Width, rect.Left + rect.Width); + int bottom = Math.Min(Top + Height, rect.Top + rect.Height); - if ((Overlapping.Left < Overlapping.Right) && (Overlapping.Top < Overlapping.Bottom)) + // If the intersection is valid (positive non zero area), then there is an intersection + if ((left < right) && (top < bottom)) { - overlap.Left = Overlapping.Left; - overlap.Top = Overlapping.Top; - overlap.Right = Overlapping.Right; - overlap.Bottom = Overlapping.Bottom; + overlap.Left = left; + overlap.Top = top; + overlap.Width = right - left; + overlap.Height = bottom - top; return true; } else { overlap.Left = 0; overlap.Top = 0; - overlap.Right = 0; - overlap.Bottom = 0; + overlap.Width = 0; + overlap.Height = 0; return false; } } @@ -136,8 +108,8 @@ namespace SFML return "[IntRect]" + " Left(" + Left + ")" + " Top(" + Top + ")" + - " Right(" + Right + ")" + - " Bottom(" + Bottom + ")"; + " Width(" + Width + ")" + + " Height(" + Height + ")"; } /// Left coordinate of the rectangle @@ -146,16 +118,15 @@ namespace SFML /// Top coordinate of the rectangle public int Top; - /// Right coordinate of the rectangle - public int Right; + /// Width of the rectangle + public int Width; - /// Bottom coordinate of the rectangle - public int Bottom; + /// Height of the rectangle + public int Height; } - //////////////////////////////////////////////////////////// /// - /// FloatRect is an utility class for manipulating 2D rectangles + /// IntRect is an utility class for manipulating 2D rectangles /// with float coordinates /// //////////////////////////////////////////////////////////// @@ -168,50 +139,15 @@ namespace SFML /// /// Left coordinate of the rectangle /// Top coordinate of the rectangle - /// Right coordinate of the rectangle - /// Bottom coordinate of the rectangle + /// Width of the rectangle + /// Height of the rectangle //////////////////////////////////////////////////////////// - public FloatRect(float left, float top, float right, float bottom) + public FloatRect(float left, float top, float width, float height) { Left = left; Top = top; - Right = right; - Bottom = bottom; - } - - //////////////////////////////////////////////////////////// - /// - /// Width of the rectangle - /// - //////////////////////////////////////////////////////////// - public float Width - { - get {return Right - Left;} - } - - //////////////////////////////////////////////////////////// - /// - /// Height of the rectangle - /// - //////////////////////////////////////////////////////////// - public float Height - { - get {return Bottom - Top;} - } - - //////////////////////////////////////////////////////////// - /// - /// Move the whole rectangle by the given offset - /// - /// Horizontal offset - /// Vertical offset - //////////////////////////////////////////////////////////// - public void Offset(float offsetX, float offsetY) - { - Left += offsetX; - Top += offsetY; - Right += offsetX; - Bottom += offsetY; + Width = width; + Height = height; } //////////////////////////////////////////////////////////// @@ -224,7 +160,7 @@ namespace SFML //////////////////////////////////////////////////////////// public bool Contains(float x, float y) { - return (x >= Left) && (x <= Right) && (y >= Top) && (y <= Bottom); + return (x >= Left) && (x < Left + Width) && (y >= Top) && (y < Top + Height); } //////////////////////////////////////////////////////////// @@ -236,8 +172,13 @@ namespace SFML //////////////////////////////////////////////////////////// public bool Intersects(FloatRect rect) { - return ((Math.Max(Left, rect.Left) < Math.Min(Right, rect.Right)) && - (Math.Max(Top, rect.Top) < Math.Min(Bottom, rect.Bottom))); + // Compute the intersection boundaries + float left = Math.Max(Left, rect.Left); + float top = Math.Max(Top, rect.Top); + float right = Math.Min(Left + Width, rect.Left + rect.Width); + float bottom = Math.Min(Top + Height, rect.Top + rect.Height); + + return (left < right) && (top < bottom); } //////////////////////////////////////////////////////////// @@ -250,25 +191,27 @@ namespace SFML //////////////////////////////////////////////////////////// public bool Intersects(FloatRect rect, out FloatRect overlap) { - FloatRect Overlapping = new FloatRect(Math.Max(Left, rect.Left), - Math.Max(Top, rect.Top), - Math.Min(Right, rect.Right), - Math.Min(Bottom, rect.Bottom)); + // Compute the intersection boundaries + float left = Math.Max(Left, rect.Left); + float top = Math.Max(Top, rect.Top); + float right = Math.Min(Left + Width, rect.Left + rect.Width); + float bottom = Math.Min(Top + Height, rect.Top + rect.Height); - if ((Overlapping.Left < Overlapping.Right) && (Overlapping.Top < Overlapping.Bottom)) + // If the intersection is valid (positive non zero area), then there is an intersection + if ((left < right) && (top < bottom)) { - overlap.Left = Overlapping.Left; - overlap.Top = Overlapping.Top; - overlap.Right = Overlapping.Right; - overlap.Bottom = Overlapping.Bottom; + overlap.Left = left; + overlap.Top = top; + overlap.Width = right - left; + overlap.Height = bottom - top; return true; } else { overlap.Left = 0; overlap.Top = 0; - overlap.Right = 0; - overlap.Bottom = 0; + overlap.Width = 0; + overlap.Height = 0; return false; } } @@ -284,8 +227,8 @@ namespace SFML return "[FloatRect]" + " Left(" + Left + ")" + " Top(" + Top + ")" + - " Right(" + Right + ")" + - " Bottom(" + Bottom + ")"; + " Width(" + Width + ")" + + " Height(" + Height + ")"; } /// Left coordinate of the rectangle @@ -294,11 +237,11 @@ namespace SFML /// Top coordinate of the rectangle public float Top; - /// Right coordinate of the rectangle - public float Right; + /// Width of the rectangle + public float Width; - /// Bottom coordinate of the rectangle - public float Bottom; + /// Height of the rectangle + public float Height; } } }