-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[Enhancement] Add brush support for background #1856
Comments
Brushes are not trivial to support on all platforms. In fact they will really slow things down quite a bit. We intentionally limited ourselves to flat colors for this reason. That said Im not opposed to someone doing some serious research on the topic assuming they are aware that unless the results are really good this is a pretty unlikely patch to be taken. |
@jassmith I appreciate the honest feedback, it's important to know you won't accept if someone do a PR for this. In this case I will close this. Can you please share more how it will "slow things down quite a bit"? The way I envisioned this to work is to just add to renderers to draw a gradient using |
pinging @jassmith |
On android you will pay a significant performance penalty for those brushes even if you using a LinearGradient drawable. Drawables aint that cheap :/ Further there will be a desire for us to add the newly introduced brush type to more and more locations, many of which can't be easily supported. |
Thanks for the ping btw, I had missed this |
@jassmith I'm not sure I am following you, but I don't think anyone expects Xamarin Forms to support brushes in a way which is more performant than the native. |
I wish I believed that was true... Regardless I think the bigger issue is once we introduce the Brush type there would be a strong push to move the Brush type everywhere possible, which would result in a lot of deprecated API/ABI. We're in a pretty tough spot with Brush. |
I wonder what it would take to put a Foreground/Background brush on every control and make them inherit properly. There would be a doozy of spec to write around that... |
Seeing more usage of gradients, and hearing it's making a comeback. SkiaSharp is great for this, and we should do a real look at supporting this everywhere in XF controls: Foreground and Background. FontIconSource with a gradient....good use case right there. Related: |
FontIconSource with a gradient would be fantastic! Would enable so many high quality decoration examples for UI. I've moved away from using .png to FontIcons and they are amazing! Smaller and far more performant than .png files for every resolution scenario. |
Unless I am mistaken this is possible now for a while already. So closing this one :) |
Rationale
Many times there's a need to have a gradient brush, especially on a
Page
. Using images is not an option.Summary
Add
Background
property toVisualElement
:public Brush Background { get; set; }
where
Brush
is apublic abstract class Brush
.Type of brushes:
public class SolidColorBrush: Brush
public class GradientBrush: Brush
public class LinearGradientBrush: GradientBrush
public class RadialGradientBrush: GradientBrush
Nothing new, these are all taken from Windows XAML (XAML Standard where art thou?)
The text was updated successfully, but these errors were encountered: