-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[API Proposal]: DrawRectangle should accept RectangleF as one of the overloads #62401
Comments
Tagging subscribers to this area: @dotnet/area-system-drawing Issue DetailsBackground and motivationIn Graphics class, FillRectangle contains the following 4 overloads:
However, DrawRectangle, contains only the following 3 overloads:
In the interest of symmetry, I propose adding the "missing" RectangleF overload:
During a development process one can quite often switch between DrawRectangle and FillRectangle API. This would allow to do so without changing the variables around, i.e. just by changing API usage would be comparable to the existing API: var rect = new RectangleF(...);
e.Graphics.FillRectangle(Brushes.Blue, rect); // this works even now
e.Graphics.DrawRectangle(Pens.Red, rect); // this would be a new overload API Proposalnamespace System.Collections.Generic
{
public class MyFancyCollection<T> : IEnumerable<T>
{
public void Fancy(T item);
}
} API Usage// Fancy the value
var c = new MyFancyCollection<int>();
c.Fancy(42);
// Getting the values out
foreach (var v in c)
Console.WriteLine(v); Alternative DesignsNo response RisksNo response
|
Makes sense to add this overload to be consistent with what we have on other APIs, i.e Marking it as api-ready-for-review to discuss it on the review meeting. |
namespace System.Drawing.Common
{
public partial class Graphics
{
public void DrawRectangle(Pen pen, RectangleF rect);
public void FillPie(Brush brush, RectangleF rect, float startAngle, float sweepAngle);
}
} |
Agreed; missed that one. I believe |
I did ask for pull request to be reopened (yes, I did things slightly out of order). Once that happens I will push commit for |
Please tag this with "in pr" 😄 thank you |
This was completed in #62385 |
Background and motivation
In Graphics class, FillRectangle contains the following 4 overloads:
public void FillRectangle(Brush brush, RectangleF rect)
public void FillRectangle(Brush brush, float x, float y, float width, float height)
public void FillRectangle(Brush brush, Rectangle rect)
public void FillRectangle(Brush brush, int x, int y, int width, int height)
However, DrawRectangle, contains only the following 3 overloads:
public void DrawRectangle(Pen pen, Rectangle rect)
public void DrawRectangle(Pen pen, float x, float y, float width, float height)
public void DrawRectangle(Pen pen, int x, int y, int width, int height)
In the interest of symmetry, I propose adding the "missing" RectangleF overload:
public void DrawRectangle(Pen pen, RectangleF rect)
During a development process one can quite often switch between DrawRectangle and FillRectangle API. This would allow to do so without changing the variables around, i.e. just by changing
Fill
intoDraw
and backward. Likewise, this would make drawing filled rectangles with outline in different color minutely easier.API Proposal
API Usage
API usage would be comparable to the existing API:
Alternative Designs
No response
Risks
Since method will just be a convenient way of calling already existing overload, risk is minimal if any.
The text was updated successfully, but these errors were encountered: