Questions tagged [colors]

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

Color is the visual perceptual property corresponding in humans to the categories called red, green, blue and others. Color derives from the spectrum of light interacting in the eye with the spectral sensitivities of the light receptors. Color categories and physical specifications of color are also associated with objects, materials, light sources, etc., based on their physical properties such as light absorption, reflection, or emission spectra. By defining a color space, colors can be identified numerically by their coordinates.

Web colors are colors used in designing web pages, and the methods for describing and specifying those colors. Hexadecimal color codes begin with a hash (#)

Authors of web pages have a variety of options available for specifying colors for elements of web documents. Colors may be specified as an RGB triplet in hexadecimal format (a hex triplet); they may also be specified according to their common English names in some cases. Often a color tool or other graphics software is used to generate color values.

Some browsers and devices do not support colors. For these and blind and colorblind users, Web content depending on colors can be unusable or difficult to use. Both foreground and background color should be modified to avoid black on black effects. Similarly, most browsers show links as shades of blue by default; therefore, dark background colors, such as blue or navy, do not display well for such links.

19393 questions
1350
votes
10 answers

Hex transparency in colors

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 searched around a bit although I couldn't find a…
SweSnow
  • 16,324
  • 9
  • 32
  • 49
700
votes
34 answers

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
  • 45,122
  • 42
  • 127
  • 254
644
votes
16 answers

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 instance for the hexadecimal color code. Is there an…
viky
  • 16,233
  • 13
  • 65
  • 88
643
votes
49 answers

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
  • 8,743
  • 6
  • 28
  • 43
584
votes
18 answers

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) for the amount to lighten or darken. To darken, pass in a…
Pimp Trizkit
  • 16,888
  • 5
  • 22
  • 37
573
votes
36 answers

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 holder is just a class and text is of type…
Vikas
  • 22,508
  • 34
  • 110
  • 159
561
votes
22 answers

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 highlighting doesn't add as much capability as it…
zslayton
  • 45,810
  • 9
  • 33
  • 48
547
votes
15 answers

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
  • 12,359
  • 6
  • 48
  • 63
538
votes
17 answers

Change color of PNG image via CSS?

Given a transparent PNG displaying a simple shape in white, is it possible to somehow change the color of this through CSS? Some kind of overlay or what not?
user429620
527
votes
16 answers

How to set Bullet colors in UL/LI html lists via CSS without using any images or span tags

Imagine a simple unsorted list with some
  • items. Now, I have defined the bullets to be square shaped via list-style:square; However, if I set the color of the
  • items with color: #F00; then everything becomes red! While I only want to set…
  • Sam
    • 15,156
    • 23
    • 85
    • 134
    510
    votes
    7 answers

    OS X Terminal Colors

    I'm new to OS X, having just gotten 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) when running ls -la or…
    sa125
    • 25,703
    • 36
    • 105
    • 149
    493
    votes
    57 answers

    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, zoomFactor: 32, levels: encoded_levels, …
    n00ki3
    • 13,009
    • 15
    • 52
    • 65
    476
    votes
    12 answers

    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 values of three seekbars to a specific level.
    ataulm
    • 14,077
    • 7
    • 44
    • 90
    456
    votes
    6 answers

    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
    • 17,505
    • 18
    • 65
    • 98
    434
    votes
    20 answers

    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 brighter, but I'm kind of at a loss as to where…
    robmerica
    • 4,683
    • 3
    • 16
    • 9
    1
    2 3
    99 100