Skip to content
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

[FEATURE] Implicit conversions between ValueTuples and SKPoint #2862

Open
1 task done
OJacot-Descombes opened this issue May 17, 2024 · 0 comments
Open
1 task done

Comments

@OJacot-Descombes
Copy link

OJacot-Descombes commented May 17, 2024

Is your feature request related to a problem?

I would like to be able to specify points in an easier way.

Describe the solution you would like

Therefore, I suggest adding an implicit conversion between a ValueTuple and a SKPoint as well as a deconstructor:

// In struct SKPoint

public static implicit operator SKPoint((float x, float y) tuple) => new SKPoint(tuple.x, tuple.y);

public void Deconstruct(out float x, out float y) => (x = X, y = Y);

This would allow us to define a point as SKPoint point = (x, y); instead of SKPoint point = new SKPoint(x, y);.

The inverse would also be possible: var (x, y) = point;.

Describe alternatives you have considered

It is currently (C#12) not possible to declare operators as extension methods.

Additional context

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant