24 bits almost always uses 8 bits of each of R, G, B. As of 2018
24-bit color depth is used by virtually every computer and phone
display and the vast majority of image storage formats. Almost all
cases where there are 32 bits per pixel mean that 24 are used for the
color, and the remaining 8 are the alpha channel or unused.

224 gives 16,777,216 color variations. The human eye can discriminate up to ten million colors[10] and since the gamut of a display is smaller than the range of human vision, this means this should cover that range with more detail than can be perceived. ...

...

Macintosh systems refer to 24-bit color as "millions of colors". The term "True color" is sometime used to mean what this article is calling "Direct color".[13] It is also often used to refer to all color depths greater or equal to 24.

All 16,777,216 colors

Task

Write a program which generates and returns all 16,777,216 color variations within an array as strings in the CSS rgb() function

5.1. The RGB functions: rgb() and rgba()

The rgb() function defines an RGB color by specifying the red,
green, and blue channels directly. Its syntax is:

The first three arguments specify the red, green, and blue channels of
the color, respectively. 0% represents the minimum value for that
color channel in the sRGB gamut, and 100% represents the maximum
value. A <number> is equivalent to a <percentage>, but with a
different range: 0 again represents the minimum value for the color
channel, but 255 represents the maximum. These values come from the
fact that many graphics engines store the color channels internally as
a single byte, which can hold integers between 0 and 255.
Implementations should honor the precision of the channel as authored
or calculated wherever possible. If this is not possible, the channel
should be rounded to the closest value at the highest precision used,
rounding up if two values are equally close.

The final argument, the <alpha-value>, specifies the alpha of the
color. If given as a <number>, the useful range of the value is 0
(representing a fully transparent color) to 1 (representing a fully
opaque color). If given as a , 0% represents a fully
transparent color, while 100% represents a fully opaque color. If
omitted, it defaults to 100%.

Values outside these ranges are not invalid, but are clamped to the
ranges defined here at computed-value time.

For legacy reasons, rgb() also supports an alternate syntax that
separates all of its arguments with commas:

The CSS hex color notation allows a color to be specified by
giving the channels as hexadecimal numbers, which is similar to how
colors are often written directly in computer code. It’s also shorter
than writing the same color out in rgb() notation.

The syntax of a <hex-color> is a <hash-token> token whose value
consists of 3, 4, 6, or 8 hexadecimal digits. In other words, a hex
color is written as a hash character, "#", followed by some number of
digits 0-9 or letters a-f (the case of the letters doesn’t matter -
#00ff00 is identical to #00FF00).

The number of hex digits given determines how to decode the hex
notation into an RGB color:

6 digits

The first pair of digits, interpreted as a hexadecimal number, specifies the red channel of the color, where 00 represents the
minimum value and ff (255 in decimal) represents the maximum. The
next pair of digits, interpreted in the same way, specifies the green
channel, and the last pair specifies the blue. The alpha channel of
the color is fully opaque.

Loops from 1 to 16mb (16777216). Each iteration, we use the -format operator acting on the current number pre-decremented --$_ against the string "#{0:x6}". Here, we're specifying hex values, padded to 6 digits, with a hash # in front. On TIO, limited to 60 seconds / 128KiB of output. Change the 1 to (16mb-5) to see how it ends.

Interesting language. Any idea why the letter T is used for "0"? I get 16 -> G to save a byte, but T -> 0 doesn't accomplish the same.
– AlecSep 24 at 20:15

@Alec Because if you replace T with 0, it joins with the 6 and becomes 06.
– geokavelSep 25 at 4:54

Ah, gotcha. So is there one letter per digit for cases where you don't want it to join with the previous/next digit?
– AlecSep 25 at 6:57

@Alec, as geokavel said, in this particular case, it saves me a byte in having to use a comma to delimit the 2 arguments being passed to ù. Another typical use case for it is to use it as a counter when you need to increment a variable while, for example, mapping over an array. And, of course, as it's a variable, you can simply assign a value to it too, if needed. 0 is the only single digit integer that has it's own variable, though - well, technically, 7 as the 6 input variable U-Z default to 0. The other integers assigned to variables in Japt are: -1, 10-16, 32, 64 & 100.
– ShaggySep 25 at 9:26

If you'd like to learn more about Japt, feel free to ping me in our chatroom.
– ShaggySep 25 at 9:27

15Ý # Create a list in the range [0, 15]
h # Convert each to a hexadecimal value
6ã # Create each possible sextuple combination of the list
J # Join them together to a single string
'#ì # And prepend a "#" before each of them

The TIO version displays the first 2^10 only as not to time out. I included the final iteration in the footer to show that it indeed terminates at #FFFFFF. Saved one byte by changing to fprintf instead of manually assembling the string. Outputs a comma-separated list.

Given enough time/memory, this anonymous function will output all \$2^{24}-1\$ color codes. To see this, you can swap the 6⍴ for a 4⍴ in the code, and you'll see it output every code with up to 4 digits.

Thanks to @Dzaima and @ngn for the 23 bytes.

Uses ⎕IO←0.

How:

'#',(⎕D,⎕A)[↑,⍳6⍴16] ⍝ Main function
⍳6⍴16 ⍝ Generate every possible 6 digit hex number in a matrix format
, ⍝ Ravel the matrix (from a 16x16x16x16x16x16 matrix to a 16^6x2 list)
↑ ⍝ Mix; (turns the list into a 16^6x2 matrix)
(⎕D,⎕A)[ ] ⍝ Use that matrix to index the vector of the digits 0-9 concatenated with the alphabet.
'#', ⍝ Then prepend a '#' to each.

Batch, 69 + 4 = 73

g.cmd, 69

for /L %%A in (0,1,16777215)do cmd/kexit %%A&set #%%A=#!=exitcode:~2!

Saves the hexadecimal value with form #RRGGBB into an 'Array'.

g.cmd is to be called using cmd /V/Q/K g.cmd. This is where the + 4 comes from, /V/Q, counting as 4 additional characters compared to just cmd /K g.cmd. This sets up an environment that has the 'Array' in memory. It also takes forever to run, so use very low values to try or break execution using Ctrl+C

Breakdown

Invokation

/V enables delayed expansion, but is shorter than setlocal EnableDelayedExpansion, which is why we need the cmd call in the first place

/Q omits the output and is equivalent to @echo off

/K lets you execute an expression (In this case g.cmd) and does not exit afterwards, so you can check the 'Array' by using set #

Ah, you posted this while I was writing my post, so we have very similar answers. You can improve by three bytes with r[i]="".format("#%06X",i);
– archangel.mjjSep 24 at 10:17

@archangel.mjj Ah, I'm an idiot. Thanks! I actually had "".format("#%06X",i) before since I saw it in the Python answer, but I dropped the answer because I couldn't get it to work fast enough for TIO. Then I saw everyone just outputting the first 4,096 items on TIO, so I wrote the answer again, forgetting about "#%06X"... >.<
– Kevin CruijssenSep 24 at 10:27

@KevinCruijssen I never knew you could do var r in Java..
– FireCubezSep 24 at 18:12

Are you sure this will ever output hex digits with the %1$06d format string? And I see no reason for using 1$. You could reduce the length by including the “#” in the format string: #%06x. Which would come handy when adding extra characters to fix the range, as currently counts up to 16777216 = #1000000.
– manatworkSep 24 at 15:27

Well, it would .... If I didn't forgot to change %d to %x. And completely forgot about moving the # inside the sprintf() call. You saved me 6 bytes. Thank you
– Ismael MiguelSep 24 at 16:45

Uses a recursive CTE for a number table from 0 to 2^24-1, then uses the built-in FORMAT command (available in SQL 2012 or later) to turn it into a 6-digit hex string. Attach the # to the front, and we're done.

Function submission (because Jelly full programs will, by default, print lists of strings with no delimiters between them, making it hard to see the boundaries). The TIO link contains a wrapper to print a list of strings using newlines to separate them.

Explanation

ØHṗ6”#;Ɱ
ØH All hex digits (“0123456789ABCDEF”)
ṗ6 Find all strings of 6 of them (order relevant, repeats allowed)
”#; Prepend “#”
Ɱ to each of the resulting strings

Out of interest -- why did you make your answer a community wiki?
– Jonathan FrechSep 25 at 1:53

@JonathanFrech: I do this for all my posts because a) it reduces the incentive for people to game the reputation system (as the post doesn't give reputation), b) I'm happy to have my posts edited and the community-wiki marker is a way to indicate that. Stack Exchange's reputation system is more or less completely broken: on a past account, I once intentionally rep-capped every day for a week to show how easy the system was to game. Nowadays I pretty much want no part in it, especially as higher reputation simply just makes the site try to persuade you to moderate it.
– ais523Sep 25 at 2:19

Just curious -- on which stack did you achieve to game the reputation system?
– Jonathan FrechSep 25 at 2:49

@JonathanFrech: This one. I was a 20k user, but eventually deleted my account because it was kind-of messing up my life, and because the reputation system was actively pushing me into making content that made the site worse, as opposed to better.
– ais523Sep 25 at 2:52

Your Answer

If this is an answer to a challenge…

…Be sure to follow the challenge specification. However, please refrain from exploiting obvious loopholes. Answers abusing any of the standard loopholes are considered invalid. If you think a specification is unclear or underspecified, comment on the question instead.

…Try to optimize your score. For instance, answers to code-golf challenges should attempt to be as short as possible. You can always include a readable version of the code in addition to the competitive one.
Explanations of your answer make it more interesting to read and are very much encouraged.

…Include a short header which indicates the language(s) of your code and its score, as defined by the challenge.

More generally…

…Please make sure to answer the question and provide sufficient detail.

…Avoid asking for help, clarification or responding to other answers (use comments instead).