-
Notifications
You must be signed in to change notification settings - Fork 693
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
Rounded corner Border with animatable gradient properties? #10166
Comments
Not sure if it is what you mean, but in this test I animate the gradient (CreateLinearGradientBrush, CreateColorGradientStop red to blue) from top to bottom with a translation matrix |
@castorix Yes that's essentially what I'm after. I'll have to do a bit of digging in. I had a feeling I might have to mess with the visual layer, but was hoping composition, without need for external assets, could meet my needs. But I'll happily (hopefully) use SwapChainPanel and whatever APIs if that's the only way for now. As long as there are no visual and minimal latency issues. Does anyone know:
It's my guess that SwapChain will perform best on dynamic resizing whereas other solutions sacrifice animated gradient properties ( |
I did not use a SwapChain in this test, I used CreateRoundedRectangleGeometry, CreateSpriteShape, CreateShapeVisual.Add then SetElementChildVisual at end to set it as child of an image control. |
@castorix Sorry for the misunderstanding. I've actually come to a similar solution but hit a wall when I wanted full transparency for everything but the border. The reason is that it's going to sit atop an acrylic background. Are you able to get transparency on the inner portion using that technique? The Composition animations work for this. I assume Edit: If not, maybe I could use Edit 2: |
This is the test I did inside an Image control :
XAML :
|
@castorix Oh wow, I crucially missed the option for Well, I'm glad I used it as a bit of learning opportunity in case the other options are needed for custom geometry. Thanks so much for your help. |
Well, I was able to make a close approximation of what I'm looking for. I can't help but think that using I have the gradient and animations set to values that make the desired effect obvious. Screen.Recording.2024-11-15.143628.mp4
|
I've been stuck on trying to solve this for a while. It seems like a simple problem that has a simple solution, but I'm not sure it does yet.
I'm attempting to apply an animatable gradient to a Border or border-like composition.
The closest I was able to get was applying
Microsoft.UI.Xaml.Media.RadialGradientBrush
toBorder.BorderBrush
but it doesn't seem like the gradient properties or gradient-stop properties can be animated. It seems only the entire gradient can be transformed. Is this correct?I can achieve what I want using a PNG file to represent the border and use composition to apply
Microsoft.UI.Composition.CompositionRadialGradientBrush
using aCompositionMaskBrush
. However, this doesn't really seem scalable.I was able to get close using a
NineGridBrush
withIsCenterHollow
set totrue
but I don't see a way to round the inner corners.Problems I've run into:
Microsoft.UI.Xaml.Media.RadialGradientBrush
properties can't be animated?Possible solutions:
CompositionPathGeometry
to create rounded border, feed intoCreateSpriteShape
and useCompositionRadialGradientBrush
CompositionMode
RedirectVisual
of an underlying Border element and somehow use aCompositionMaskBrush
to apply the gradient.Hope this isn't too much of an edge case 😉
The text was updated successfully, but these errors were encountered: