Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

[Enhancement] Add brush support for background #1856

Closed
andreinitescu opened this issue Feb 9, 2018 · 12 comments · Fixed by #9220
Closed

[Enhancement] Add brush support for background #1856

andreinitescu opened this issue Feb 9, 2018 · 12 comments · Fixed by #9220
Labels
in-progress This issue has an associated pull request that may resolve it! m/high impact ⬛ proposal-accepted t/enhancement ➕

Comments

@andreinitescu
Copy link
Contributor

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 to VisualElement:

public Brush Background { get; set; }

where Brush is a public 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?)

@jassmith
Copy link

jassmith commented Feb 9, 2018

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.

@andreinitescu
Copy link
Contributor Author

andreinitescu commented Feb 10, 2018

@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 CALayer on iOS, android.graphics.LinearGradient (or just GradientDrawable) on Android, LinearGradientBrush on UWP.

@andreinitescu
Copy link
Contributor Author

pinging @jassmith

@jassmith
Copy link

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.

@jassmith
Copy link

Thanks for the ping btw, I had missed this

@andreinitescu
Copy link
Contributor Author

@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.

@jassmith
Copy link

jassmith commented Feb 17, 2018

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.

@jassmith
Copy link

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...

@davidortinau
Copy link
Contributor

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:
davidortinau/VisualChallenge#23
https://auroracontrols.app

@ghost
Copy link

ghost commented Jun 13, 2019

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.

@samhouts samhouts added inactive Issue is older than 6 months and needs to be retested help wanted We welcome community contributions to any issue, but these might be a good place to start! up-for-grabs We welcome community contributions to any issue, but these might be a good place to start! labels Dec 13, 2019
@jsuarezruiz jsuarezruiz mentioned this issue Jan 15, 2020
2 tasks
@samhouts samhouts added the in-progress This issue has an associated pull request that may resolve it! label Jan 15, 2020
@samhouts samhouts added inactive Issue is older than 6 months and needs to be retested help wanted We welcome community contributions to any issue, but these might be a good place to start! up-for-grabs We welcome community contributions to any issue, but these might be a good place to start! and removed help wanted We welcome community contributions to any issue, but these might be a good place to start! inactive Issue is older than 6 months and needs to be retested up-for-grabs We welcome community contributions to any issue, but these might be a good place to start! labels Jan 15, 2020
@jfversluis
Copy link
Member

Unless I am mistaken this is possible now for a while already. So closing this one :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
in-progress This issue has an associated pull request that may resolve it! m/high impact ⬛ proposal-accepted t/enhancement ➕
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants