# Show the input RGB color [closed]

Write a program that takes R, G, and B values as command arguments and then displays that color some way. It doesn't matter how, as long as at least 100 pixels have the color. Shortest code wins.

• This would be improved a lot if you specified how much of the input colour should be displayed. Is just one pixel OK? I recommend you make it a requirement that the screen/window background colour (or the majority of the screen/window) be displayed in the input colour. Even so, it's rather simple. Jun 23 '14 at 19:24
• Is COLOR command of Windows prompt valid? It has only 16 possibilities of color from 0 to F Nov 2 '17 at 22:09
• I should win it! Nov 19 '17 at 22:33

## JavaScript, 25

document.bgColor=prompt()


You'll have to specify the three components in hexadecimal. This is code golf, so no commas or whitespace.

• Hexadecimal: cheeky, but I like it! Jun 23 '14 at 22:46
• Wouldn't you need a '#'+, then?
– Doorknob
Jun 24 '14 at 23:25
• @Doorknob: HTML is too cool to choke on malformed input: stackoverflow.com/questions/8318911/… Jun 24 '14 at 23:56
• I should win it! Nov 2 '17 at 21:34

# JavaScript, 57 characters

document.body.setAttribute('bgcolor','rgb('+prompt()+')')


Enter the RGB values in the prompt input box, comma separated.

(I feel so dirty, using bgcolor :O )

• bgcolor? That really brings me back to a simpler time...
– qwr
Jun 23 '14 at 19:54

xterm -bg \#$1$2$3  Input the color as three 1- or 2-digit hex numbers, e.g., if this command is in the file "xterm.sh", then ./xterm.sh ff 00 00 ./xterm.sh f 0 0  opens a terminal window with a red background. If you prefer, you can omit the blanks between the components: ./xterm.sh f00  The "-bg" option is not available in some old versions of xterm. It's missing from version 271 but present in versions 215, 251, 261, and 297. # Bash, 69 read c;set$c;printf '\e]4;1;rgb:'"$1"'/'"$2"'/'"$3"'\e\\\e[31mc\e[m'  Partially stolen from here. Just input your values in hex (e.g. FF 00 00). Tested on xterm-256color. # Bash, 43 printf '\e]4;1;rgb:FF/00/00\e\\\e[31mc\e[m'  Here you have to input the values yourself. Edit: For 100 Pixels+ Just choose font-size infinite :D. C# WPF : 54 new Windows(){Background=Color.FromArgb(RGB);}.Show();  # Javascript in PCCG, 65 105 Edit 2 shortened as suggested by @manatwork Edit Thanks @blender question.style.background='#'+prompt('R G B').split(' ').join('')  Just for fun • You can replace document.getElementById('question') with just question. Jun 23 '14 at 22:28 • You can assign to the background property. (As a side effect will reset backgroundImage and alike, but not a problem in this case.) Aug 7 '14 at 14:36 ## Bash/sh + ImageMagick: 28 bytes display -size 96 xc:\#$1$2$3


Input the color as three 1- or 2-digit hex numbers, with or without whitespace between them.

• I was thinking xsetroot -solid '#xyz', but this is better. (And the effect of xsetroot is only visible if you aren't using a desktop environment that covers the X11 root window with a window showing a background, rather than drawing the background on the root window directly.) Aug 6 '14 at 9:05
• xterm is shorter: "xterm -bg \#$1$2$3"; I'll post that as a new answer. Aug 6 '14 at 12:22 # Postscript 61 56 Fills the graphics window with the color, components as decimals in the range 0..1. ARGUMENTS{cvr}forall setrgbcolor clippath fill showpage  Run using ghostscript's -- option which enables argument processing. gs -- rgb.ps .9 .2 .2  # Java, 215 import java.awt.*;class C{public static void main(String[]a){Frame f=new Frame();f.setSize(9,99);f.setBackground(new Color(Integer.parseInt(a[0]),Integer.parseInt(a[1]),Integer.parseInt(a[2])));f.setVisible(true);}}  # Tcl/Tk, 15 . co -bg #$argv


. configure -bg #$argv  If called with wish show_color.tcl 6666AA  one gets # Tcl/Tk, 27 grid [canvas .c -bg #$argv]


If called with

wish show_color.tcl 6666AA


one gets