Skip to main content

Questions tagged [colors]

Use this tag for questions about representing or manipulating colors in a programming language.

Filter by
Sorted by
Tagged with
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 ...
SweSnow's user avatar
  • 17.3k
1274 votes
47 answers
3.0m 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 { ...
Barbara's user avatar
  • 14.3k
1009 votes
42 answers
641k 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?
MaiaVictor's user avatar
  • 52.4k
834 votes
61 answers
838k 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).
Sindar's user avatar
  • 10.7k
711 votes
20 answers
690k 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 ...
viky's user avatar
  • 17.5k
710 votes
23 answers
350k 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) ...
Pimp Trizkit's user avatar
  • 19.6k
684 votes
23 answers
321k 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 ...
zslayton's user avatar
  • 52.3k
655 votes
33 answers
677k 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.
creativecreatorormaybenot's user avatar
618 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 ...
Vikas's user avatar
  • 24.3k
615 votes
17 answers
244k 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.
daniel kullmann's user avatar
604 votes
19 answers
389k 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 ...
jotch's user avatar
  • 6,246
592 votes
29 answers
1.0m 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 ...
Basit's user avatar
  • 16.9k
575 votes
65 answers
923k 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, ...
n00ki3's user avatar
  • 14.8k
562 votes
23 answers
486k 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 ...
robmerica's user avatar
  • 5,963
550 votes
16 answers
943k 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: #...
Sam's user avatar
  • 15.5k
548 votes
48 answers
385k 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 ...
airmind's user avatar
  • 7,821
544 votes
22 answers
487k 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): ...
Dave Dopson's user avatar
  • 42.4k
540 votes
7 answers
508k 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) ...
sa125's user avatar
  • 28.7k
535 votes
13 answers
470k 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 ...
ataulm's user avatar
  • 15.3k
528 votes
8 answers
528k 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 ...
ThiefMaster's user avatar
521 votes
7 answers
504k 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.
Ollie Glass's user avatar
  • 19.9k
489 votes
17 answers
657k 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.
Taranath Datta's user avatar
420 votes
13 answers
226k 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 ...
MauroPorras's user avatar
  • 5,143
399 votes
16 answers
409k 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?
Macha's user avatar
  • 14.6k
385 votes
27 answers
154k 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 ...
DJPB's user avatar
  • 5,649
369 votes
16 answers
440k 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 ...
Johann's user avatar
  • 12.3k
340 votes
6 answers
705k 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: ...
T.C. Proctor's user avatar
  • 6,356
340 votes
23 answers
788k 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&...
HUSTEN's user avatar
  • 5,177
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 ...
SteveCl's user avatar
  • 4,559
331 votes
16 answers
156k 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 ...
Brian Gianforcaro's user avatar
319 votes
27 answers
467k 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.
rui's user avatar
  • 11.2k
315 votes
11 answers
180k 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 ...
oldhomemovie's user avatar
311 votes
16 answers
379k 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 ...
Li Haoyi's user avatar
  • 15.6k
305 votes
23 answers
100k 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 ...
Joseph Daigle's user avatar
300 votes
14 answers
268k 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?
NibblyPig's user avatar
  • 52.4k
283 votes
20 answers
324k 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 ...
patrick's user avatar
  • 7,459
277 votes
9 answers
302k 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 ...
LondonRob's user avatar
  • 77k
252 votes
16 answers
146k 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 ...
RileyE's user avatar
  • 11k
252 votes
24 answers
249k 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.
hhafez's user avatar
  • 39.4k
251 votes
20 answers
180k 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 ...
job's user avatar
  • 9,193
250 votes
22 answers
195k 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 ...
Pawel P.'s user avatar
  • 3,959
249 votes
19 answers
196k 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 ...
Darragh Enright's user avatar
246 votes
14 answers
150k 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 #...
Bosah Chude's user avatar
  • 3,740
243 votes
12 answers
354k 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 ...
Mnementh's user avatar
  • 51.1k
234 votes
7 answers
463k 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 ...
pottigopi's user avatar
  • 2,349
233 votes
10 answers
182k 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="#...
Thiago's user avatar
  • 4,812
232 votes
20 answers
198k 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 ...
Ana Fernandes's user avatar
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, ...
Joel H.'s user avatar
  • 2,784
219 votes
18 answers
146k 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 ...
Arash's user avatar
  • 12.2k
215 votes
6 answers
76k 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 ...
radarek's user avatar
  • 2,608

1
2 3 4 5
439