Fade image to transparent like a gradient

If you want this: You can do this: <html> <style type=”text/css”> div, img { position:absolute; top:0; left:0; width:250px; height:250px; } img { -webkit-mask-image:-webkit-gradient(linear, left top, left bottom, from(rgba(0,0,0,1)), to(rgba(0,0,0,0))); mask-image: linear-gradient(to bottom, rgba(0,0,0,1), rgba(0,0,0,0)); } </style> <body> <div>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi sit amet porttitor massa. Morbi eget tortor congue, aliquet … Read more

Matplotlib: How to colorize a large number of line segments as independent gradients, efficiently

One (minor) speedup would be adding a single line collection instead of 10000 separate line collections. As long as all of the lines share the same colormap, you can group them into a single line collection, and each can still have an independent gradient. Matplotlib is still slow for this sort of thing. It’s optimized … Read more

Android LinearLayout Gradient Background

Ok I have managed to solve this using a selector. See code below: main_header.xml: <?xml version=”1.0″ encoding=”utf-8″?> <LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android” android:layout_width=”fill_parent” android:layout_height=”50dip” android:orientation=”horizontal” android:background=”@drawable/main_header_selector”> </LinearLayout> main_header_selector.xml: <?xml version=”1.0″ encoding=”utf-8″?> <selector xmlns:android=”http://schemas.android.com/apk/res/android”> <item> <shape> <gradient android:angle=”90″ android:startColor=”#FFFF0000″ android:endColor=”#FF00FF00″ android:type=”linear” /> </shape> </item> </selector> Hopefully this helps someone who has the same problem.

Angle gradient in canvas

A context strokeStyle can be a gradient: // create a gradient gradient = ctx.createLinearGradient(xStart, yStart, xEnd, yEnd); gradient.addColorStop(0.0,”blue”); gradient.addColorStop(1.0,”purple”); // stroke using that gradient ctx.strokeStyle = gradient; Example code and a Demo using a gradient strokeStyle: http://jsfiddle.net/m1erickson/w46ps/ <!doctype html> <html> <head> <link rel=”stylesheet” type=”text/css” media=”all” href=”https://stackoverflow.com/questions/22223950/css/reset.css” /> <!– reset css –> <script type=”text/javascript” src=”http://code.jquery.com/jquery.min.js”></script> <style> … Read more

SVG gradient for perfectly horizontal path

The default for gradientUnits is objectBoundingBox. The key issue you have is described in the last paragraph of the specification text… Keyword objectBoundingBox should not be used when the geometry of the applicable element has no width or no height, such as the case of a horizontal or vertical line, even when the line has … Read more

Changing gradient background colors on Android at runtime

Yes! Found a way! Had to forget about XML, but here’s how I did it: On my getView() overloaded function (ListAdapter) I just had to: int h = v.getHeight(); ShapeDrawable mDrawable = new ShapeDrawable(new RectShape()); mDrawable.getPaint().setShader(new LinearGradient(0, 0, 0, h, Color.parseColor(“#330000FF”), Color.parseColor(“#110000FF”), Shader.TileMode.REPEAT)); v.setBackgroundDrawable(mDrawable); And that gave me the same result as the XML background … Read more

CSS gradient checkerboard pattern

Just modify the background-position like in the below snippet to get the required output. This works fine in Firefox, Chrome, Opera, IE11 and Edge. body { background-image: linear-gradient(45deg, #808080 25%, transparent 25%), linear-gradient(-45deg, #808080 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #808080 75%), linear-gradient(-45deg, transparent 75%, #808080 75%); background-size: 20px 20px; background-position: 0 0, 0 10px, … Read more