Point, PointF, Size and SizeF: Unary minus operator
- Dominant language
- C#
- Stars
- 4.9k
- Forks
- 1.1k
- Avg merge
- 1d 13m
- Merged PRs (30d)
- 85
Description
### Background and motivation
I propose to add a unary minus operator to the Point, PointF, Size and SizeF structs. It is to improve readability during drawing operations.
### API Proposal
```csharp
namespace System.Drawing;
public struct Point
{
public static Point operator -(Point value) { return new Point(-value.X, -value.Y); }
}
public struct PointF
{
public static PointF operator -(PointF value) { return new PointF(-value.X, -value.Y); }
}
public struct Size
{
public static Size operator -(Size value) { return new Size(-value.Width, -value.Height); }
}
public struct SizeF
{
public static SizeF operator -(SizeF value) { return new SizeF(-value.Width, -value.Height); }
}
```
### API Usage
```csharp
// Translate
graphics.TranslateTransform(
pntLocation
);
// Reverse translate
graphics.TranslateTransform(
-pntLocation
);
```
### Alternative Designs
_No response_
### Risks
_No response_
### Will this feature affect UI controls?
No impact on UI controls.
Contributor guide
Assessment
This issue has not been assessed yet.