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

Allow GradientBrush's GradientStops to be unordered #16151

Open
dbriard opened this issue Jun 27, 2024 · 4 comments
Open

Allow GradientBrush's GradientStops to be unordered #16151

dbriard opened this issue Jun 27, 2024 · 4 comments

Comments

@dbriard
Copy link
Contributor

dbriard commented Jun 27, 2024

Is your feature request related to a problem? Please describe.

Currently we have to manually sort the GradientStops by offset in order to have the correct rendering, while in WPF the gradient stop collection can be in any order, and is automatically sorted during the rendering.

Describe the solution you'd like

I would like to add GradientStop in any order, and have the correct rendering. Order should not matter.

Describe alternatives you've considered

No response

Additional context

Or may be it is a bug?

@timunie
Copy link
Contributor

timunie commented Jun 28, 2024

Sorting adds some overhead. Is there a real use case where we can't expect the devs to order them on their own?

@Gillibald
Copy link
Contributor

Sorting adds some overhead. Is there a real use case where we can't expect the devs to order them on their own?

Sorting can be done at compile time. So in most cases, this should not impact performance.

@dbriard
Copy link
Contributor Author

dbriard commented Jun 28, 2024

Sorting adds some overhead. Is there a real use case where we can't expect the devs to order them on their own?

I understand but that's a bit weird that this do not work like WPF or UWP.
Sometime to flip a gradient, I just copy/paste and switch the offsets.

My use case is porting a GradientBrushEditor control that I used in WPF to Avalonia.

One idea, may a as Gilibald suggested, sort the stops declared in XAML at compile time, and only dynamically sort Brushes created from Code? Generally there is no many stops, so the overhead should be limited.

@kekekeks
Copy link
Member

Is there a real use case where we can't expect the devs to order them on their own?

That's WPF behavior, actually. We automatically sort gradient stops before passing those to Avalonia in XPF.

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

4 participants