Tutorial by Examples: color

You can customize your theme’s color palette. Using framework APIs 5.0 <style name="AppTheme" parent="Theme.Material"> <item name="android:colorPrimary">@color/primary</item> <item name="android:colorPrimaryDark">@color/pri...
To get any random color: function randomColor():uint { return Math.random() * 0xFFFFFF; } If you need more control over the red, green and blue channels: var r:uint = Math.random() * 0xFF; var g:uint = Math.random() * 0xFF; var b:uint = Math.random() * 0xFF; var color:uint = r <&...
If you set opacity on an element it will affect all its child elements. To set an opacity just on the background of an element you will have to use RGBA colors. Following example will have a black background with 0.6 opacity. /* Fallback for web browsers that don't support RGBa */ background-color...
Objective-C mySwitch.backgroundColor = [UIColor yellowColor]; [mySwitch setBackgroundColor: [UIColor yellowColor]]; mySwitch.backgroundColor =[UIColor colorWithRed:255/255.0 green:0/255.0 blue:0/255.0 alpha:1.0]; mySwitch.backgroundColor= [UIColor colorWithWhite: 0.5 alpha: 1.0]; mySwitch.backg...
Objective-C //for off-state mySwitch.tintColor = [UIColor blueColor]; [mySwitch setTintColor: [UIColor blueColor]]; //for on-state mySwitch.onTintColor = [UIColor cyanColor]; [mySwitch setOnTintColor: [UIColor cyanColor]]; Swift //for off-state mySwitch.tintColor = UIColor.blueColor() ...
You can create a UIColor from a hexadecimal number or string, e.g. 0xff00cc, "#FFFFFF" Swift Int Value extension UIColor { convenience init(hex: Int, alpha: CGFloat = 1.0) { let r = CGFloat((hex >> 16) & 0xff) / 255 let g = CGFloat((hex >> 08) &amp...
In MATLAB versions prior to R2014b, using the old HG1 graphics engine, it was not obvious how to create color coded 2D line plots. With the release of the new HG2 graphics engine arose a new undocumented feature introduced by Yair Altman: n = 100; x = linspace(-10,10,n); y = x.^2; p = plot(x,y,'r...
A list of recognised color keyword names can be found in the W3C Recommendation for SVG. <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <circle r="30" cx="100" cy="100" fill="red" stroke=&qu...
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <circle r="30" cx="100" cy="100" fill="#ff0000" stroke="#00ff00" /> <rect x="200" y="200" width="50&...
Protocol Oriented Programming is a useful tool in order to easily write better unit tests for our code. Let's say we want to test a UIViewController that relies on a ViewModel class. The needed steps on the production code are: Define a protocol that exposes the public interface of the class Vi...
//Swift imageView.tintColor = UIColor.redColor() imageView.image = imageView.image?.imageWithRenderingMode(.AlwaysTemplate) //Swift 3 imageView.tintColor = UIColor.red imageView.image = imageView.image?.withRenderingMode(.alwaysTemplate) //Objective-C imageView.tintColor = [UIColor redCol...
Go to File -> Settings -> Editor -> Colors & Fonts -> Android Logcat Change the colors as you need: Choose the appropriate color:
Swift let color = UIColor.redColor() let size = CGSize(width: 200, height: 200) UIGraphicsBeginImageContextWithOptions(size, false, 0.0) CGContextSetFillColorWithColor(UIGraphicsGetCurrentContext(), color.CGColor) CGContextFillRect(UIGraphicsGetCurrentContext(), CGRect(origin: .zero, size: si...
<style name="AppTheme" parent="Theme.AppCompat"> <item name="android:colorEdgeEffect">@color/my_color</item> </style>
5.0 The ripple animation is shown when user presses clickable views. You can use the same ripple color used by your app assigning the ?android:colorControlHighlight in your views. You can customize this color by changing the android:colorControlHighlight attribute in your theme: This effect colo...
5.0 This attribute is used to change the navigation bar (one, that contain Back, Home Recent button). Usually it is black, however it's color can be changed. <style name="AppTheme" parent="Theme.AppCompat"> <item name="android:navigationBarColor">@col...
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <circle r="30" cx="100" cy="100" fill="rgb(255, 0, 0)" stroke="rgb(0, 255, 0)" /> <rect x="200" y="200" w...
Hex Opacity Values ------------------------------ | Alpha(%) | Hex Value | ------------------------------ | 100% | FF | | 95% | F2 | | 90% | E6 | | 85% | D9 | | 80% | ...
Vim comes with several pre-installed color schemes. In Linux, the color schemes that come with Vim are stored in /usr/share/vim/vim74/colors/ (where 74 is your version number, sans periods); MacVim stores them in /Applications/MacVim.app/Contents/Resources/vim/runtime/colors. Changing Color Schemes...
Apart from the built-in colormaps defined in the colormaps reference (and their reversed maps, with '_r' appended to their name), custom colormaps can also be defined. The key is the matplotlib.cm module. The below example defines a very simple colormap using cm.register_cmap, containing a single c...

Page 2 of 6