# Show the input RGB color

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. – Level River St Jun 23 '14 at 19:24
• Is COLOR command of Windows prompt valid? It has only 16 possibilities of color from 0 to F – sergiol Nov 2 '17 at 22:09
• I should win it! – sergiol 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! – Level River St 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/… – Blender Jun 24 '14 at 23:56
• I should win it! – sergiol Nov 2 '17 at 21:34

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. # 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 # Python 3, 65 from webbrowser import* open("http://www.colorhexa.com/"+input())  Requires input in hexadecimal form. If a more human-friendly input format is required, you can accept comma-separated decimal input in 118 characters: from webbrowser import* open('http://www.colorhexa.com/'+''.join(hex(int(n))[2:].zfill(2)for n in input().split(',')))  # 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. – Blender 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.) – manatwork 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.) – Peter Cordes Aug 6 '14 at 9:05
• xterm is shorter: "xterm -bg \#$1$2$3"; I'll post that as a new answer. – Glenn Randers-Pehrson 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
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 1, "mathjax_display_tex": 0, "mathjax_asciimath": 1, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "math_score": 0.36651816964149475, "perplexity": 4119.896950785506}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 20, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "warc_path": "s3://commoncrawl/crawl-data/CC-MAIN-2020-24/segments/1590348492295.88/warc/CC-MAIN-20200604223445-20200605013445-00174.warc.gz"}