Skip to content

[FEATURE] Implicit conversions between ValueTuples and SKPoint #2862

Open

Description

@OJacot-Descombes

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 an implicit operator as extension method.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/SkiaSharptriage/triagedtype/feature-request

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions