How can I do programmatically gradient border color UIButton with Swift [closed]

let gradient = CAGradientLayer() gradient.frame = CGRect(origin: CGPointZero, size: self.myButton.frame.size) gradient.colors = [UIColor.blueColor().CGColor, UIColor.greenColor().CGColor] let shape = CAShapeLayer() shape.lineWidth = 2 shape.path = UIBezierPath(rect: self.myButton.bounds).CGPath shape.strokeColor = UIColor.blackColor().CGColor shape.fillColor = UIColor.clearColor().CGColor gradient.mask = shape self.myButton.layer.addSublayer(gradient) Swift 3 version: let gradient = CAGradientLayer() gradient.frame = CGRect(origin: CGPoint.zero, size: self.myButton.frame.size) gradient.colors = [UIColor.blue.cgColor, UIColor.green.cgColor] let shape = … Read more

How to set status bar background as gradient color or a drawable in Android?

For some one who want to set gradient color to status bar background you can use following method in your activity before setContentView() For Java @TargetApi(Build.VERSION_CODES.LOLLIPOP) public static void setStatusBarGradiant(Activity activity) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { Window window = activity.getWindow(); Drawable background = activity.getResources().getDrawable(R.drawable.gradient_theme); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.setStatusBarColor(activity.getResources().getColor(android.R.color.transparent)); window.setNavigationBarColor(activity.getResources().getColor(android.R.color.transparent)); window.setBackgroundDrawable(background); } } For Kotlin @TargetApi(Build.VERSION_CODES.LOLLIPOP) fun … Read more

How to plot a gradient color line

Note that if you have many points, calling plt.plot for each line segment can be quite slow. It’s more efficient to use a LineCollection object. Using the colorline recipe you could do the following: import matplotlib.pyplot as plt import numpy as np import matplotlib.collections as mcoll import matplotlib.path as mpath def colorline( x, y, z=None, … Read more

2D grid data visualization in Python

Matplotlib has the imshow method for plotting arrays: import matplotlib as mpl from matplotlib import pyplot import numpy as np # make values from -5 to 5, for this example zvals = np.random.rand(100,100)*10-5 # make a color map of fixed colors cmap = mpl.colors.ListedColormap([‘blue’,’black’,’red’]) bounds=[-6,-2,2,6] norm = mpl.colors.BoundaryNorm(bounds, cmap.N) # tell imshow about color map … Read more

Why can’t I reference an SVG linear gradient defined in an external file (paint server)?

After more research, it looks like this is a browser support issue. See: https://code.google.com/p/chromium/issues/detail?id=109212 https://bugs.webkit.org/show_bug.cgi?id=105904 Sadly, I’d come across this question before posting mine, and had thought that surely, in 5-1/2 years, browser support would have caught up – but that doesn’t appear to be the case. As of 2015, apparently Firefox and Opera are … Read more

Machine learning – Linear regression using batch gradient descent

The error is very simple. Your delta declaration should be inside the first for loop. Every time you accumulate the weighted differences between the training sample and output, you should start accumulating from the beginning. By not doing this, what you’re doing is accumulating the errors from the previous iteration which takes the error of … Read more

Awful background image quality in Android

First of all, make sure that your original image looks good so you’re not just getting the problem from there. Then, in your onCreate() method, do: code1: getWindow().getDecorView().getBackground().setDither(true); getWindow().setFormat(PixelFormat.RGBA_8888); Deprecated: getWindow().addFlags(WindowManager.LayoutParams.FLAG_DITHER); And to load your image explicitly as a 32-bit image (RGBA-8888 configuration) add the following where you load your views: code2: BitmapFactory.Options options = … Read more

Generating gradients programmatically?

you want an interpolation between the first and the second colour. Interpolating colours is easy by calculating the same interpolation for each of its components (R, G, B). There are many ways to interpolate. The easiest is to use linear interpolation: just take percentage p of the first colour and percentage 1 – p of … Read more

Applying a Gradient to CAShapeLayer

You could use the path of your shape to create a masking layer and apply that on the gradient layer, like this: UIView *v = [[UIView alloc] initWithFrame:self.window.frame]; CAShapeLayer *gradientMask = [CAShapeLayer layer]; gradientMask.fillColor = [[UIColor clearColor] CGColor]; gradientMask.strokeColor = [[UIColor blackColor] CGColor]; gradientMask.lineWidth = 4; gradientMask.frame = CGRectMake(0, 0, v.bounds.size.width, v.bounds.size.height); CGMutablePathRef t = … Read more

Fixed gradient background with css

If you wish to do this using CSS3 gradients, try using the background-attachment property For example, if you are applying your gradients to #background, then add this after the CSS gradient. background-attachment: fixed; Note: You must add background-attachment after the background properties. Your entire code might look like this: #background { background: #1e5799; background: -webkit-gradient(linear, … Read more