Sorry, the Forum is closed :(

Unfortunately, the forum is now closed.

Please read the following post for further details.

We apologize for the inconvenience.
The SharpDX team.
Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC: Rectangle Usage?

Rectangle Usage? 1 year 11 months ago #1209


  • Posts:15
  • Xanather's Avatar
  • Xanather
  • Fresh Boarder
  • OFFLINE
Does anyone know why the SharpDX.Rectangle has left, top, right and bottom fields. Shouldn't it be X, Y, Width, Height (seems easier to use?).

There is also a SharpDX.DrawingRectangle class which does this but it still seems odd, Also should the Rectangle class(s) have a intersect method?

Thanks,
Xanather.
The administrator has disabled public write access.

Re: Rectangle Usage? 1 year 10 months ago #1324


  • Posts:1
  • psysight's Avatar
  • psysight
  • Fresh Boarder
  • OFFLINE
I have the same question to ask. Maybe it's beacuse I always used to do in this way, when using XNA.
Also, i ported a little 2D game made in XNA, and I'm having trouble with the collission detection, since I didn't find the Intersect method for Rectangle. There's maybe another way to draw and test collision between Texture2D objects without using Rectangles?
Sorry if it seems a dumb question, but I'm pretty new to DX world :)
The administrator has disabled public write access.

Re: Rectangle Usage? 1 year 10 months ago #1326


  • Posts:843 Thank you received: 1
  • xoofx's Avatar
  • xoofx
  • Administrator
  • OFFLINE
Xanather wrote:
Does anyone know why the SharpDX.Rectangle has left, top, right and bottom fields. Shouldn't it be X, Y, Width, Height (seems easier to use?).
The DrawingRectangle and SharpDX.Rectangle struct are an historical choice in SharpDX and a side effect of System.Drawing removed from .NET Core (in WinRT). SharpDX.Rectangle is used by several DirectX APIs that are expecting to have Left,Top, Right, Bottom serialized like this. So SharpDX was only defining this class. In the past, there was no DrawingRectangle, but because System.Drawing rectangle was removed, and in order to keep some SharpDX API that were using it, DrawingRectangle was introduced. Note that there is an implicit cast between the two.
Xanather wrote:
There is also a SharpDX.DrawingRectangle class which does this but it still seems odd, Also should the Rectangle class(s) have a intersect method?
Both objects are used for interop and so far not used for performing operations on it, but feel free to contribute to it (via github and a pull request). A bit of reflector on System.Drawing.Rectangle should give you enough idea about how to implement it.
The administrator has disabled public write access.

[Breaking Changes] to DrawingRectangle/Rectangle, DrawingPoint, DrawingSize 1 year 7 months ago #2629


  • Posts:843 Thank you received: 1
  • xoofx's Avatar
  • xoofx
  • Administrator
  • OFFLINE
In order to clean-up the API, latest dev package version is introducing some breaking changes on the following classes:
  • Remove of SharpDX.DrawingRectangle and SharpDX.DrawingRectangleF. Use SharpDX.Rectangle and SharpDX.RectangleF instead
  • Change interpretation of SharpDX.Rectangle/RectangleF constructor from (left, top, right, bottom) to (x, y, width, height). Whenever you add a new SharpDX.Rectangle(...), check your usages
  • Remove of SharpDX.DrawingPointF. Use Vector2 instead.
  • Rename of SharpDX.DrawingPoint to SharpDX.Point.
  • Rename of SharpDX.DrawingSize and SharpDX.DrawingSizeF to SharpDX.Size2 and SharpDX.Size2F.
Make sure to test your code against this new version as It will be part of 2.5 final release.
Last Edit: 1 year 7 months ago by xoofx.
The administrator has disabled public write access.
  • Page:
  • 1
Time to create page: 0.169 seconds