Gradient of n colors ranging from color 1 and color 2

colorRampPalette could be your friend here: colfunc <- colorRampPalette(c(“black”, “white”)) colfunc(10) # [1] “#000000” “#1C1C1C” “#383838” “#555555” “#717171” “#8D8D8D” “#AAAAAA” # [8] “#C6C6C6” “#E2E2E2” “#FFFFFF” And just to show it works: plot(rep(1,10),col=colfunc(10),pch=19,cex=3)

Multi-gradient shapes

I don’t think you can do this in XML (at least not in Android), but I’ve found a good solution posted here that looks like it’d be a great help! ShapeDrawable.ShaderFactory sf = new ShapeDrawable.ShaderFactory() { @Override public Shader resize(int width, int height) { LinearGradient lg = new LinearGradient(0, 0, width, height, new int[]{Color.GREEN, Color.GREEN, … Read more

How to set a gradient background in a Material Button from Material Components?

Starting with the version 1.2.0-alpha06 you can use the android:background attribute in the MaterialButton. <MaterialButton app:backgroundTint=”@null” android:background=”@drawable/button_gradient” … /> Otherwise if you can’t use the 1.2.0-alpha06 or higher you have to use the AppCompatButton component. Just a some tips about the MaterialButton. Currently the backgroundTint is still the default MaterialButton style. If you are using … Read more

CSS3 Transparency + Gradient

Yes. You can use rgba in both webkit and moz gradient declarations: /* webkit example */ background-image: -webkit-gradient( linear, left top, left bottom, from(rgba(50,50,50,0.8)), to(rgba(80,80,80,0.2)), color-stop(.5,#333333) ); (src) /* mozilla example – FF3.6+ */ background-image: -moz-linear-gradient( rgba(255, 255, 255, 0.7) 0%, rgba(255, 255, 255, 0) 95% ); (src) Apparently you can even do this in … Read more

Gradients on UIView and UILabels On iPhone [duplicate]

I realize this is an older thread, but for future reference: As of iPhone SDK 3.0, custom gradients can be implemented very easily, without subclassing or images, by using the new CAGradientLayer: UIView *view = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 100)] autorelease]; CAGradientLayer *gradient = [CAGradientLayer layer]; gradient.frame = view.bounds; gradient.colors = [NSArray arrayWithObjects:(id)[[UIColor blackColor] … Read more

Gradient borders

WebKit now (and Chrome 12 at least) supports gradients as border image: -webkit-border-image: -webkit-gradient(linear, left top, left bottom, from(#00abeb), to(#fff), color-stop(0.5, #fff), color-stop(0.5, #66cc00)) 21 30 30 21 repeat repeat; Prooflink — http://www.webkit.org/blog/1424/css3-gradients/ Browser support: http://caniuse.com/#search=border-image

Use CSS3 transitions with gradient backgrounds

Gradients don’t support transitions yet (although the current spec says they should support like gradient to like gradient transitions via interpolation.). If you want a fade-in effect with a background gradient, you have to set an opacity on a container element and ‘transition` the opacity. (There have been some browser releases that supported transitions on … Read more

How do I combine a background-image and CSS3 gradient on the same element?

Multiple backgrounds! body { background: #eb01a5; background-image: url(“IMAGE_URL”); /* fallback */ background-image: url(“IMAGE_URL”), linear-gradient(#eb01a5, #d13531); /* W3C */ } These 2 lines are the fallback for any browser that doesn’t do gradients. See notes for stacking images only IE < 9 below. Line 1 sets a flat background color. Line 2 sets the background image … Read more