-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
feat: Composition brush #20181
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
base: master
Are you sure you want to change the base?
feat: Composition brush #20181
Conversation
|
You can test this PR using the following package version. |
src/Avalonia.Base/Rendering/Composition/Server/ServerRenderResource.cs
Outdated
Show resolved
Hide resolved
| Quaternion, | ||
| Color | ||
| Color, | ||
| RelativePoint, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should probably add ctors to FFI too, e. g.
Avalonia/src/Avalonia.Base/Rendering/Composition/Expressions/BuiltInExpressionFfi.cs
Lines 131 to 136 in 5198744
| "ColorRGB", (float a, float r, float g, float b) => Avalonia.Media.Color.FromArgb( | |
| (byte) MathUtilities.Clamp(a, 0, 255), | |
| (byte) MathUtilities.Clamp(r, 0, 255), | |
| (byte) MathUtilities.Clamp(g, 0, 255), | |
| (byte) MathUtilities.Clamp(b, 0, 255) | |
| ) |
Not sure how to handle RelativeUnit there, might need a separate VariantType and separate ffi functions as enum value "ctors".
| <Property Name="TileMode" Type="Avalonia.Media.TileMode" /> | ||
| </Object> | ||
| </NComposition> | ||
| <Object Name="CompositionBrush" ServerBase="ServerRenderResource"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@maxkatz6 I think we might want to mirror UWP API here rather than Avalonia one, at least for the sake of compatibility. This needs an API review
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general our RelativePoint system felt a bit cumbersome to use compared to MS MappingMode one. We could use XPF approach to map brushes (see MuceRadialGradientBrush).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general our RelativePoint system felt a bit cumbersome to use compared to MS MappingMode one.
If we handle RelativeUnit directly like I'm currently doing, we may have to override their operators such as + - * /, which may not be a good way
|
You can test this PR using the following package version. |
|
You can test this PR using the following package version. |
This pull request implements composition brush types that conform to Avalonia's brush interfaces. It also introduces new interpolators for
RelativePointandRelativeScalarto support smooth brush animations, and adds a new interactive "Composition brush" demo to theCompositionPagein the ControlCatalog sample.These changes collectively provide a robust demonstration and infrastructure for animated composition brushes in Avalonia, both in the UI sample and the underlying rendering system.
What does the pull request do?
Composition brush implementation:
ServerCompositionBrush,ServerCompositionGradientBrush, etc.) that implement Avalonia's brush interfaces, including property change tracking and deserialization for gradient stops and spread methods.Animation infrastructure improvements:
RelativePointInterpolatorandRelativeScalarInterpolatorto enable smooth animation ofRelativePointandRelativeScalarproperties, which are essential for animating gradient brush parameters.Composition brush demo and animation support:
CompositionPage.axaml, featuring interactive UI elements for creating and animating solid, linear, radial, and conic composition brushes with animated properties and gradient stops.How was the solution implemented (if it's not obvious)?
#20150 (comment)
Checklist
Breaking changes
None
Obsoletions / Deprecations
None
Fixed issues
fixed #20150