Questions tagged [colors]
Use this tag for questions about representing or manipulating colors in a programming language.
                                	
	colors
    
                            
                        
                    
            21,873
            questions
        
        
            1446
            votes
        
        
            8
            answers
        
        
            1.3m
            views
        
    Hex transparency in colors [duplicate]
                I'm working on implementing a widget transparency option for my app widget although I'm having some trouble getting the hex color values right. Being completely new to hex color transparency I ...
            
        
       
    
            1228
            votes
        
        
            46
            answers
        
        
            2.9m
            views
        
    How can I change the color of an 'svg' element?
                I want to use this technique and change the SVG color, but so far I haven't been able to do so. I use this in the CSS, but my image is always black, no matter what.
My code:
.change-my-color {
  ...
            
        
       
    
            990
            votes
        
        
            40
            answers
        
        
            625k
            views
        
    How to change node.js's console font color?
                I had to change the console background color to white because of eye problems, but the font is gray colored and it makes the messages unreadable. How can I change it?
            
        
       
    
            822
            votes
        
        
            61
            answers
        
        
            821k
            views
        
    RGB to hex and hex to RGB
                How to convert colors in RGB format to hex format and vice versa?
For example, convert '#0080C0' to (0, 128, 192).
            
        
       
    
            708
            votes
        
        
            20
            answers
        
        
            681k
            views
        
    How do I get the color from a hexadecimal color code using .NET?
                How can I get a color from a hexadecimal color code (e.g. #FFDFD991)?
I am reading a file and am getting a hexadecimal color code. I need to create the corresponding System.Windows.Media.Color ...
            
        
       
    
            703
            votes
        
        
            23
            answers
        
        
            341k
            views
        
    Programmatically Lighten or Darken a hex color (or rgb, and blend colors)
                Here is a function I was working on to programmatically lighten or darken a hex color by a specific amount. Just pass in a string like "3F6D2A" for the color (col) and a base10 integer (amt) ...
            
        
       
    
            678
            votes
        
        
            23
            answers
        
        
            313k
            views
        
    Colorized grep -- viewing the entire file with highlighted matches
                I find grep's --color=always flag to be tremendously useful. However, grep only prints lines with matches (unless you ask for context lines). Given that each line it prints has a match, the ...
            
        
       
    
            644
            votes
        
        
            33
            answers
        
        
            653k
            views
        
    How do I use hexadecimal color strings in Flutter?
                How do I convert a hexadecimal color string like #b74093 to a Color in Flutter?
I want to use a HEX color code in Dart.
            
        
       
    
            616
            votes
        
        
            40
            answers
        
        
            1.3m
            views
        
    How to set the text color of TextView in code?
                In XML, we can set a text color by the textColor attribute, like android:textColor="#FF0000". But how do I change it by coding?
I tried something like:
holder.text.setTextColor(R.color.Red);
Where ...
            
        
       
    
            611
            votes
        
        
            17
            answers
        
        
            241k
            views
        
    How to colorize diff on the command line
                When I have a diff, how can I colorize it so that it looks good?
I want it for the command line, so please no GUI solutions.
            
        
       
    
            580
            votes
        
        
            28
            answers
        
        
            997k
            views
        
    Dynamically change color to lighter or darker by percentage CSS
                We have a big application on the site and we have a few links which are, let's say blue color like the blue links on this site. Now I want to make some other links, but with lighter color. Obviously I ...
            
        
       
    
            578
            votes
        
        
            18
            answers
        
        
            363k
            views
        
    How do I apply opacity to a CSS color variable?
                I am designing an app in electron, so I have access to CSS variables. I have defined a color variable in vars.css:
:root {
  --color: #f0f0f0;
}
I want to use this color in main.css, but with some ...
            
        
       
    
            572
            votes
        
        
            65
            answers
        
        
            911k
            views
        
    Random color generator
                Given this function, I want to replace the color with a random color generator.
document.overlay = GPolyline.fromEncoded({
    color: "#0000FF",
    weight: 10,
    points: encoded_points,
    ...
            
        
       
    
            555
            votes
        
        
            22
            answers
        
        
            472k
            views
        
    Formula to determine perceived brightness of RGB color
                I'm looking for some kind of formula or algorithm to determine the brightness of a color given the RGB values.  I know it can't be as simple as adding the RGB values together and having higher sums be ...
            
        
       
    
            549
            votes
        
        
            16
            answers
        
        
            939k
            views
        
    How to set Bullet colors in UL/LI html lists via CSS without using any images or span tags [duplicate]
                Imagine a simple unsorted list with some <li> items. Now, I have defined the bullets to be square shaped via  list-style:square; However, if I set the color of the <li> items with color: #...
            
        
       
    
            540
            votes
        
        
            48
            answers
        
        
            367k
            views
        
    How can I color Python logging output?
                Some time ago, I saw a Mono application with colored output, presumably because of its log system (because all the messages were standardized). 
Now, Python has the logging module, which lets you ...
            
        
       
    
            540
            votes
        
        
            7
            answers
        
        
            503k
            views
        
    OS X Terminal Colors [closed]
                I just got a Mac after working with Ubuntu Linux for some time. Among the many things I'm trying to figure out is the absence of colors in my terminal window- like the ones that are shown (on Linux) ...
            
        
       
    
            535
            votes
        
        
            13
            answers
        
        
            466k
            views
        
    How can I get color-int from color resource?
                Is there any way to get a color-int from a color resource?
I am trying to get the individual red, blue and green components of a color defined in the resource (R.color.myColor) so that I can set the ...
            
        
       
    
            531
            votes
        
        
            23
            answers
        
        
            468k
            views
        
    How to add color to GitHub's README.md file
                I have a README.md file for my project underscore-cli, and I want to document the --color flag.
Currently, the only way to do this is with a screenshot (which can be stored in the project repository):
...
            
        
       
    
            513
            votes
        
        
            7
            answers
        
        
            494k
            views
        
    SVG fill color transparency / alpha?
                Is it possible to set a transparency or alpha level on SVG fill colours?
I've tried adding two values to the fill tag (changing it from fill="#044B94" to fill="#044B9466"), but this doesn't work.
            
        
       
    
            503
            votes
        
        
            8
            answers
        
        
            493k
            views
        
    List of ANSI color escape sequences
                On most terminals it is possible to colorize output using the \033 ANSI escape sequence.
I'm looking for a list of all supported colors and options (like bright and blinking).
As there are probably ...
            
        
       
    
            486
            votes
        
        
            17
            answers
        
        
            644k
            views
        
    How to print color in console using System.out.println?
                How can I print color in console? I want to show data in colors when the processor sends data and in different colors when it receives data.
            
        
       
    
            418
            votes
        
        
            13
            answers
        
        
            223k
            views
        
    How to color the Git console?
                I recently saw that the git console in Windows is colored, e.g. Green for additions, red for deletions, etc. How do I color my git console like that?
To install it, I used the command: $ sudo apt-get ...
            
        
       
    
            394
            votes
        
        
            16
            answers
        
        
            402k
            views
        
    How do I output coloured text to a Linux terminal?
                How do I print coloured characters to a Linux terminal that supports it?
How do I tell whether the terminal supports colour codes?
            
        
       
    
            379
            votes
        
        
            27
            answers
        
        
            148k
            views
        
    How to decide font color in white or black depending on background color?
                I want to show some images like this example
The fill color is decided by a field in the data base with the color in hex (ex:ClassX -> Color: #66FFFF).
Now, I want to show data above a fill with the ...
            
        
       
    
            367
            votes
        
        
            16
            answers
        
        
            434k
            views
        
    How to get a Color from hexadecimal Color String
                I'd like to use a color from an hexa string such as "#FFFF0000" to (say) change the background color of a Layout.
Color.HSVToColor looks like a winner but it takes a float[] as a parameter.
Am I any ...
            
        
       
    
            340
            votes
        
        
            23
            answers
        
        
            780k
            views
        
    Can I change the color of Font Awesome's cog icon?
                I have to wrap my icon within an <a> tag for some reason.
Is there any possible way to change the color of a font-awesome icon to black?
or is it impossible as long as it wrapped within an <a&...
            
        
       
    
            338
            votes
        
        
            6
            answers
        
        
            651k
            views
        
    Named colors in matplotlib
                What named colors are available in matplotlib for use in plots?  I can find a list on the matplotlib documentation that claims that these are the only names:
b: blue
g: green
r: red
c: cyan
m: ...
            
        
       
    
            338
            votes
        
        
            18
            answers
        
        
            518k
            views
        
    jQuery animate backgroundColor
                I am trying to animate a change in backgroundColor using jQuery on mouseover.
I have checked some example and I seem to have it right, it works with other properties like fontSize, but with ...
            
        
       
    
            330
            votes
        
        
            16
            answers
        
        
            154k
            views
        
    Algorithm to randomly generate an aesthetically-pleasing color palette [closed]
                I'm looking for a simple algorithm to generate a large number of random, aesthetically pleasing colors. So no crazy neon colors, colors reminiscent of feces, etc. 
I've found solutions to this ...
            
        
       
    
            316
            votes
        
        
            27
            answers
        
        
            456k
            views
        
    How to echo with different colors in the Windows command line
                I know that the color bf command sets the colors of the whole command line window but I wanted to to print one single line in a different color.
            
        
       
    
            315
            votes
        
        
            11
            answers
        
        
            178k
            views
        
    How can I use Ruby to colorize the text output to a terminal?
                Using Ruby, how can I perform background and foreground text colorization for output in the terminal?
I remember, when programming Pascal we all used to write our own textcolor(…) procedures to make ...
            
        
       
    
            303
            votes
        
        
            23
            answers
        
        
            98k
            views
        
    Determine font color based on background color
                Given a system (a website for instance) that lets a user customize the background color for some section but not the font color (to keep number of options to a minimum), is there a way to ...
            
        
       
    
            303
            votes
        
        
            15
            answers
        
        
            366k
            views
        
    CSS hexadecimal RGBA?
                I know you can write ...
background-color: #ff0000;
... if you want something that is red.
And you can write ...
background-color: rgba(255, 0, 0, 0.5);
... if you want something red and ...
            
        
       
    
            292
            votes
        
        
            14
            answers
        
        
            257k
            views
        
    Is it possible to write to the console in colour in .NET?
                Writing a small command line tool, it would be nice to output in different colours. Is this possible?
            
        
       
    
            278
            votes
        
        
            19
            answers
        
        
            316k
            views
        
    How can I define colors as variables in CSS?
                I’m working on a CSS file that is quite long. I know that the client could ask for changes to the color scheme, and was wondering: is it possible to assign colors to variables, so that I can just ...
            
        
       
    
            272
            votes
        
        
            10
            answers
        
        
            290k
            views
        
    Getting individual colors from a color map in matplotlib
                If you have a Colormap cmap, for example:
cmap = matplotlib.cm.get_cmap('Spectral')
How can you get a particular colour out of it between 0 and 1, where 0 is the first colour in the map and 1 is the ...
            
        
       
    
            251
            votes
        
        
            24
            answers
        
        
            244k
            views
        
    HSL to RGB color conversion
                I am looking for an algorithm to convert between HSL color to RGB.
It seems to me that HSL is not very widely used so I am not having much luck searching for a converter.
            
        
       
    
            250
            votes
        
        
            16
            answers
        
        
            145k
            views
        
    Change UITextField and UITextView Cursor / Caret Color
                I'm wondering about changing the color of the cursor / caret in a UITextField (And UITextView if its the same answer) in iOS. I've seen answers for OSX development, but nothing for iOS.
Is this even ...
            
        
       
    
            248
            votes
        
        
            20
            answers
        
        
            178k
            views
        
    How to automatically generate N "distinct" colors?
                I wrote the two methods below to automatically select N distinct colors. It works by defining a piecewise linear function on the RGB cube. The benefit of this is you can also get a progressive scale ...
            
        
       
    
            245
            votes
        
        
            19
            answers
        
        
            190k
            views
        
    Create a hexadecimal colour based on a string with JavaScript
                I want to create a function that will accept any old string (will usually be a single word) and from that somehow generate a hexadecimal value between #000000 and #FFFFFF, so I can use it as a colour ...
            
        
       
    
            244
            votes
        
        
            22
            answers
        
        
            187k
            views
        
    Removing colors from output
                I have some script that produces output with colors and I need to remove the ANSI codes.
#!/bin/bash
exec > >(tee log)   # redirect the output to a file but keep it on stdout
exec 2>&1
...
            
        
       
    
            243
            votes
        
        
            13
            answers
        
        
            148k
            views
        
    How to convert a color integer to a hex String in Android?
                I have an integer that was generated from an android.graphics.Color.
It has a value of -16776961. How do I convert it into a hex string with the format #RRGGBB?
Simply put: I would like to output #...
            
        
       
    
            236
            votes
        
        
            12
            answers
        
        
            340k
            views
        
    How can I change the color of my prompt in zsh (different from normal text)?
                To recognize better the start and the end of output on a commandline, I want to change the color of my prompt, so that it is visibly different from the programs output. As I use zsh, can anyone give ...
            
        
       
    
            233
            votes
        
        
            10
            answers
        
        
            181k
            views
        
    Understanding colors on Android (six characters)
                I am trying to understand how colors work in Android. I have this color set as the background of my LinearLayout, and I get a background gray with some transparency:
<gradient android:startColor="#...
            
        
       
    
            232
            votes
        
        
            7
            answers
        
        
            459k
            views
        
    How to get different colored lines for different plots in a single figure
                I am using matplotlib to create the plots. I have to identify each plot with a different color which should be automatically generated by Python.
Can you please give me a method to put different ...
            
        
       
    
            232
            votes
        
        
            20
            answers
        
        
            194k
            views
        
    How to compare two colors for similarity/difference
                I want to design a program that can help me assess between 5 pre-defined colors which one is more similar to a variable color, and with what percentage.  The thing is that I don't know how to do that ...
            
        
       
    
            229
            votes
        
        
            15
            answers
        
        
            155k
            views
        
    How can I get the iOS 7 default blue color programmatically?
                I'm creating custom elements in my app and want to match the look and feel of the new iOS. iOS 7 introduced to us a very common lighter blue color, the default color or tint for several elements, ...
            
        
       
    
            218
            votes
        
        
            17
            answers
        
        
            142k
            views
        
    How to change color of CircularProgressIndicator
                How can I change the color of CircularProgressIndicator?
The value of the color is an instance of Animation<Color>, but I am hoping there is a simpler way to change the color without trouble of ...
            
        
       
    
            213
            votes
        
        
            6
            answers
        
        
            74k
            views
        
    Coloring white space in git-diff's output
                Regarding code formatting I'm kind of purist :). I very often remove unnecessary white spaces (lines with only ws, ws at the end of lines etc). I even have set vim to show that kind of lines colored ...