Generate an RGB colour grid Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) The PPCG Site design is on its way - help us make it awesome! Sandbox for Proposed ChallengesShort drawing programmeICS Maritime Flag alphabetGolf Wars Episode I: The Phantom LightsabersA 4x4 ChallengeThere's an ant on my Rubik's CubeReverse Bayer Filter of an imageFoam Bath LettersRoboZZle interpreterRGB to Xterm Color ConverterSub-pixel Zooming

Multi tool use
What do you call a plan that's an alternative plan in case your initial plan fails?
What does this icon in iOS Stardew Valley mean?
Black hole density
How does the particle を relate to the verb 行く in the structure「A を + B に行く」?
How do I stop a creek from eroding my steep embankment?
Are two submodules (where one is contained in the other) isomorphic if their quotientmodules are isomorphic?
What are the pros and cons of Aerospike nosecones?
Is there a (better) way to access $wpdb results?
What is Arya's weapon design?
Why are Kinder Surprise Eggs illegal in the USA?
Coloring maths inside a tcolorbox
51k Euros annually for a family of 4 in Berlin: Is it enough?
How widely used is the term Treppenwitz? Is it something that most Germans know?
How discoverable are IPv6 addresses and AAAA names by potential attackers?
How to deal with a team lead who never gives me credit?
How do database operations (write, update, alter) on particular cell in a table are written to disk without overwriting entire file?
How to react to hostile behavior from a senior developer?
What is the role of the transistor and diode in a soft start circuit?
What exactly is a "Meth" in Altered Carbon?
Is the Standard Deduction better than Itemized when both are the same amount?
What is the meaning of the new sigil in Game of Thrones Season 8 intro?
How to prevent mathematica rounding extremely small numbers to zero?
The logistics of corpse disposal
How can I make names more distinctive without making them longer?
Generate an RGB colour grid
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
The PPCG Site design is on its way - help us make it awesome!
Sandbox for Proposed ChallengesShort drawing programmeICS Maritime Flag alphabetGolf Wars Episode I: The Phantom LightsabersA 4x4 ChallengeThere's an ant on my Rubik's CubeReverse Bayer Filter of an imageFoam Bath LettersRoboZZle interpreterRGB to Xterm Color ConverterSub-pixel Zooming
$begingroup$
This! is an RGB colour grid...
Basically it's a 2-dimensional matrix in which:
- The first row, and the first column, are red.
- The second row, and the second column, are green.
- The third row, and the third column, are blue.
Here are the colours described graphically, using the letters R, G, and B.
Here's how we calculate the colour of each space on the grid is calculated.
- Red + Red = Red (#FF0000)
- Green + Green = Green (#00FF00)
- Blue + Blue = Blue (#0000FF)
- Red + Green = Yellow (#FFFF00)
- Red + Blue = Purple (#FF00FF)
- Green + Blue = Teal (#00FFFF)
The Challenge
- Write code to generate an RGB colour grid.
- It's code golf, so attempt to do so in the smallest number of bytes.
- Use any programming language or markup language to generate your grid.
- Things I care about:
- The result should graphically display an RGB grid with the defined colours.
- Things I don't care about:
- If the output is an image, HTML, SVG or other markup.
- The size or shape of the colour blocks.
- Borders, spacing etc between or around the blocks.
- It definitely doesn't have to have labels telling you what the row and column colours should be.
code-golf graphical-output
$endgroup$
add a comment |
$begingroup$
This! is an RGB colour grid...
Basically it's a 2-dimensional matrix in which:
- The first row, and the first column, are red.
- The second row, and the second column, are green.
- The third row, and the third column, are blue.
Here are the colours described graphically, using the letters R, G, and B.
Here's how we calculate the colour of each space on the grid is calculated.
- Red + Red = Red (#FF0000)
- Green + Green = Green (#00FF00)
- Blue + Blue = Blue (#0000FF)
- Red + Green = Yellow (#FFFF00)
- Red + Blue = Purple (#FF00FF)
- Green + Blue = Teal (#00FFFF)
The Challenge
- Write code to generate an RGB colour grid.
- It's code golf, so attempt to do so in the smallest number of bytes.
- Use any programming language or markup language to generate your grid.
- Things I care about:
- The result should graphically display an RGB grid with the defined colours.
- Things I don't care about:
- If the output is an image, HTML, SVG or other markup.
- The size or shape of the colour blocks.
- Borders, spacing etc between or around the blocks.
- It definitely doesn't have to have labels telling you what the row and column colours should be.
code-golf graphical-output
$endgroup$
add a comment |
$begingroup$
This! is an RGB colour grid...
Basically it's a 2-dimensional matrix in which:
- The first row, and the first column, are red.
- The second row, and the second column, are green.
- The third row, and the third column, are blue.
Here are the colours described graphically, using the letters R, G, and B.
Here's how we calculate the colour of each space on the grid is calculated.
- Red + Red = Red (#FF0000)
- Green + Green = Green (#00FF00)
- Blue + Blue = Blue (#0000FF)
- Red + Green = Yellow (#FFFF00)
- Red + Blue = Purple (#FF00FF)
- Green + Blue = Teal (#00FFFF)
The Challenge
- Write code to generate an RGB colour grid.
- It's code golf, so attempt to do so in the smallest number of bytes.
- Use any programming language or markup language to generate your grid.
- Things I care about:
- The result should graphically display an RGB grid with the defined colours.
- Things I don't care about:
- If the output is an image, HTML, SVG or other markup.
- The size or shape of the colour blocks.
- Borders, spacing etc between or around the blocks.
- It definitely doesn't have to have labels telling you what the row and column colours should be.
code-golf graphical-output
$endgroup$
This! is an RGB colour grid...
Basically it's a 2-dimensional matrix in which:
- The first row, and the first column, are red.
- The second row, and the second column, are green.
- The third row, and the third column, are blue.
Here are the colours described graphically, using the letters R, G, and B.
Here's how we calculate the colour of each space on the grid is calculated.
- Red + Red = Red (#FF0000)
- Green + Green = Green (#00FF00)
- Blue + Blue = Blue (#0000FF)
- Red + Green = Yellow (#FFFF00)
- Red + Blue = Purple (#FF00FF)
- Green + Blue = Teal (#00FFFF)
The Challenge
- Write code to generate an RGB colour grid.
- It's code golf, so attempt to do so in the smallest number of bytes.
- Use any programming language or markup language to generate your grid.
- Things I care about:
- The result should graphically display an RGB grid with the defined colours.
- Things I don't care about:
- If the output is an image, HTML, SVG or other markup.
- The size or shape of the colour blocks.
- Borders, spacing etc between or around the blocks.
- It definitely doesn't have to have labels telling you what the row and column colours should be.
code-golf graphical-output
code-golf graphical-output
asked 1 hour ago
AJFaradayAJFaraday
3,52143259
3,52143259
add a comment |
add a comment |
5 Answers
5
active
oldest
votes
$begingroup$
Wolfram Language (Mathematica), 41 bytes
Image@Outer[Plus,#,#,1]&@IdentityMatrix@3
Wolfram Language (Mathematica), 68 bytes
Mathematica has built-ins for all these colors.
Image@Red,Yellow,Magenta,Yellow,Green,Cyan,Magenta,Cyan,Blue
$endgroup$
add a comment |
$begingroup$
Wolfram Language (Mathematica), 72 bytes
Grid@Partition[RGBColor/@Unitize[Total/@Tuples[IdentityMatrix@3,2]],3]
$endgroup$
add a comment |
$begingroup$
Perl 6 (and probably similar for many languages) (31 bytes)
'ÿ ÿÿÿ ÿ ÿÿ ÿ ÿÿÿ ÿ ÿÿ ÿ' # replace spaces with ASCII 00
# which I can't seem to enter
This outputs a headless TIFF file, which used to be generated by Photoshop with the file extension .raw and is presumed to be square unless otherwise specified at the time of opening. Playing around with the color depth (if allowed) could reduce this down further.
$endgroup$
add a comment |
$begingroup$
GFA Basic 2.02 (Atari ST), 48 bytes
A manually edited listing in .LST format. Includes many non-printable characters, whose codes are shown within brackets.
?"[ESC]c[SOH] [ESC]c[ETX] [ESC]c[ENQ] "[CR]
?"[ESC]c[ETX] [ESC]c[STX] [ESC]c[ACK] "[CR]
?"[ESC]c[ENQ] [ESC]c[ACK] [ESC]c[EOT] "[CR]
The operating system of the Atari ST defines extended VT52 commands which are used here.
Output
The output is a block of $24times24$ pixels (9 space characters of $8times8$ pixels).
screenshot from Steem SSE
$endgroup$
add a comment |
$begingroup$
HTML/CSS, 278 bytes
.acolor:#ff0.bcolor:#f0f.ccolor:#0ff
<table><tr><td style="color:red">█</td><td class=a>█</td><td class=b>█</td></tr><tr><td class=a>█</td><td style="color:#0f0">█</td><td class=c>█</td></tr><tr><td class=b>█</td><td class=c>█</td><td style="color:#00f">█
Uses Unicode █
(U+2588) for the "blocks", and uses CSS classes/inline style to color them.
Uses a HTML table for layout, this is probably the part most susceptible to golfing
$endgroup$
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "200"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f183315%2fgenerate-an-rgb-colour-grid%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
5 Answers
5
active
oldest
votes
5 Answers
5
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
Wolfram Language (Mathematica), 41 bytes
Image@Outer[Plus,#,#,1]&@IdentityMatrix@3
Wolfram Language (Mathematica), 68 bytes
Mathematica has built-ins for all these colors.
Image@Red,Yellow,Magenta,Yellow,Green,Cyan,Magenta,Cyan,Blue
$endgroup$
add a comment |
$begingroup$
Wolfram Language (Mathematica), 41 bytes
Image@Outer[Plus,#,#,1]&@IdentityMatrix@3
Wolfram Language (Mathematica), 68 bytes
Mathematica has built-ins for all these colors.
Image@Red,Yellow,Magenta,Yellow,Green,Cyan,Magenta,Cyan,Blue
$endgroup$
add a comment |
$begingroup$
Wolfram Language (Mathematica), 41 bytes
Image@Outer[Plus,#,#,1]&@IdentityMatrix@3
Wolfram Language (Mathematica), 68 bytes
Mathematica has built-ins for all these colors.
Image@Red,Yellow,Magenta,Yellow,Green,Cyan,Magenta,Cyan,Blue
$endgroup$
Wolfram Language (Mathematica), 41 bytes
Image@Outer[Plus,#,#,1]&@IdentityMatrix@3
Wolfram Language (Mathematica), 68 bytes
Mathematica has built-ins for all these colors.
Image@Red,Yellow,Magenta,Yellow,Green,Cyan,Magenta,Cyan,Blue
answered 1 hour ago
alephalphaalephalpha
21.9k33094
21.9k33094
add a comment |
add a comment |
$begingroup$
Wolfram Language (Mathematica), 72 bytes
Grid@Partition[RGBColor/@Unitize[Total/@Tuples[IdentityMatrix@3,2]],3]
$endgroup$
add a comment |
$begingroup$
Wolfram Language (Mathematica), 72 bytes
Grid@Partition[RGBColor/@Unitize[Total/@Tuples[IdentityMatrix@3,2]],3]
$endgroup$
add a comment |
$begingroup$
Wolfram Language (Mathematica), 72 bytes
Grid@Partition[RGBColor/@Unitize[Total/@Tuples[IdentityMatrix@3,2]],3]
$endgroup$
Wolfram Language (Mathematica), 72 bytes
Grid@Partition[RGBColor/@Unitize[Total/@Tuples[IdentityMatrix@3,2]],3]
answered 1 hour ago


J42161217J42161217
14.1k21353
14.1k21353
add a comment |
add a comment |
$begingroup$
Perl 6 (and probably similar for many languages) (31 bytes)
'ÿ ÿÿÿ ÿ ÿÿ ÿ ÿÿÿ ÿ ÿÿ ÿ' # replace spaces with ASCII 00
# which I can't seem to enter
This outputs a headless TIFF file, which used to be generated by Photoshop with the file extension .raw and is presumed to be square unless otherwise specified at the time of opening. Playing around with the color depth (if allowed) could reduce this down further.
$endgroup$
add a comment |
$begingroup$
Perl 6 (and probably similar for many languages) (31 bytes)
'ÿ ÿÿÿ ÿ ÿÿ ÿ ÿÿÿ ÿ ÿÿ ÿ' # replace spaces with ASCII 00
# which I can't seem to enter
This outputs a headless TIFF file, which used to be generated by Photoshop with the file extension .raw and is presumed to be square unless otherwise specified at the time of opening. Playing around with the color depth (if allowed) could reduce this down further.
$endgroup$
add a comment |
$begingroup$
Perl 6 (and probably similar for many languages) (31 bytes)
'ÿ ÿÿÿ ÿ ÿÿ ÿ ÿÿÿ ÿ ÿÿ ÿ' # replace spaces with ASCII 00
# which I can't seem to enter
This outputs a headless TIFF file, which used to be generated by Photoshop with the file extension .raw and is presumed to be square unless otherwise specified at the time of opening. Playing around with the color depth (if allowed) could reduce this down further.
$endgroup$
Perl 6 (and probably similar for many languages) (31 bytes)
'ÿ ÿÿÿ ÿ ÿÿ ÿ ÿÿÿ ÿ ÿÿ ÿ' # replace spaces with ASCII 00
# which I can't seem to enter
This outputs a headless TIFF file, which used to be generated by Photoshop with the file extension .raw and is presumed to be square unless otherwise specified at the time of opening. Playing around with the color depth (if allowed) could reduce this down further.
answered 56 mins ago
guifaguifa
29115
29115
add a comment |
add a comment |
$begingroup$
GFA Basic 2.02 (Atari ST), 48 bytes
A manually edited listing in .LST format. Includes many non-printable characters, whose codes are shown within brackets.
?"[ESC]c[SOH] [ESC]c[ETX] [ESC]c[ENQ] "[CR]
?"[ESC]c[ETX] [ESC]c[STX] [ESC]c[ACK] "[CR]
?"[ESC]c[ENQ] [ESC]c[ACK] [ESC]c[EOT] "[CR]
The operating system of the Atari ST defines extended VT52 commands which are used here.
Output
The output is a block of $24times24$ pixels (9 space characters of $8times8$ pixels).
screenshot from Steem SSE
$endgroup$
add a comment |
$begingroup$
GFA Basic 2.02 (Atari ST), 48 bytes
A manually edited listing in .LST format. Includes many non-printable characters, whose codes are shown within brackets.
?"[ESC]c[SOH] [ESC]c[ETX] [ESC]c[ENQ] "[CR]
?"[ESC]c[ETX] [ESC]c[STX] [ESC]c[ACK] "[CR]
?"[ESC]c[ENQ] [ESC]c[ACK] [ESC]c[EOT] "[CR]
The operating system of the Atari ST defines extended VT52 commands which are used here.
Output
The output is a block of $24times24$ pixels (9 space characters of $8times8$ pixels).
screenshot from Steem SSE
$endgroup$
add a comment |
$begingroup$
GFA Basic 2.02 (Atari ST), 48 bytes
A manually edited listing in .LST format. Includes many non-printable characters, whose codes are shown within brackets.
?"[ESC]c[SOH] [ESC]c[ETX] [ESC]c[ENQ] "[CR]
?"[ESC]c[ETX] [ESC]c[STX] [ESC]c[ACK] "[CR]
?"[ESC]c[ENQ] [ESC]c[ACK] [ESC]c[EOT] "[CR]
The operating system of the Atari ST defines extended VT52 commands which are used here.
Output
The output is a block of $24times24$ pixels (9 space characters of $8times8$ pixels).
screenshot from Steem SSE
$endgroup$
GFA Basic 2.02 (Atari ST), 48 bytes
A manually edited listing in .LST format. Includes many non-printable characters, whose codes are shown within brackets.
?"[ESC]c[SOH] [ESC]c[ETX] [ESC]c[ENQ] "[CR]
?"[ESC]c[ETX] [ESC]c[STX] [ESC]c[ACK] "[CR]
?"[ESC]c[ENQ] [ESC]c[ACK] [ESC]c[EOT] "[CR]
The operating system of the Atari ST defines extended VT52 commands which are used here.
Output
The output is a block of $24times24$ pixels (9 space characters of $8times8$ pixels).
screenshot from Steem SSE
edited 42 mins ago
answered 1 hour ago


ArnauldArnauld
81.3k797335
81.3k797335
add a comment |
add a comment |
$begingroup$
HTML/CSS, 278 bytes
.acolor:#ff0.bcolor:#f0f.ccolor:#0ff
<table><tr><td style="color:red">█</td><td class=a>█</td><td class=b>█</td></tr><tr><td class=a>█</td><td style="color:#0f0">█</td><td class=c>█</td></tr><tr><td class=b>█</td><td class=c>█</td><td style="color:#00f">█
Uses Unicode █
(U+2588) for the "blocks", and uses CSS classes/inline style to color them.
Uses a HTML table for layout, this is probably the part most susceptible to golfing
$endgroup$
add a comment |
$begingroup$
HTML/CSS, 278 bytes
.acolor:#ff0.bcolor:#f0f.ccolor:#0ff
<table><tr><td style="color:red">█</td><td class=a>█</td><td class=b>█</td></tr><tr><td class=a>█</td><td style="color:#0f0">█</td><td class=c>█</td></tr><tr><td class=b>█</td><td class=c>█</td><td style="color:#00f">█
Uses Unicode █
(U+2588) for the "blocks", and uses CSS classes/inline style to color them.
Uses a HTML table for layout, this is probably the part most susceptible to golfing
$endgroup$
add a comment |
$begingroup$
HTML/CSS, 278 bytes
.acolor:#ff0.bcolor:#f0f.ccolor:#0ff
<table><tr><td style="color:red">█</td><td class=a>█</td><td class=b>█</td></tr><tr><td class=a>█</td><td style="color:#0f0">█</td><td class=c>█</td></tr><tr><td class=b>█</td><td class=c>█</td><td style="color:#00f">█
Uses Unicode █
(U+2588) for the "blocks", and uses CSS classes/inline style to color them.
Uses a HTML table for layout, this is probably the part most susceptible to golfing
$endgroup$
HTML/CSS, 278 bytes
.acolor:#ff0.bcolor:#f0f.ccolor:#0ff
<table><tr><td style="color:red">█</td><td class=a>█</td><td class=b>█</td></tr><tr><td class=a>█</td><td style="color:#0f0">█</td><td class=c>█</td></tr><tr><td class=b>█</td><td class=c>█</td><td style="color:#00f">█
Uses Unicode █
(U+2588) for the "blocks", and uses CSS classes/inline style to color them.
Uses a HTML table for layout, this is probably the part most susceptible to golfing
.acolor:#ff0.bcolor:#f0f.ccolor:#0ff
<table><tr><td style="color:red">█</td><td class=a>█</td><td class=b>█</td></tr><tr><td class=a>█</td><td style="color:#0f0">█</td><td class=c>█</td></tr><tr><td class=b>█</td><td class=c>█</td><td style="color:#00f">█
.acolor:#ff0.bcolor:#f0f.ccolor:#0ff
<table><tr><td style="color:red">█</td><td class=a>█</td><td class=b>█</td></tr><tr><td class=a>█</td><td style="color:#0f0">█</td><td class=c>█</td></tr><tr><td class=b>█</td><td class=c>█</td><td style="color:#00f">█
answered 33 mins ago


SkidsdevSkidsdev
6,5662977
6,5662977
add a comment |
add a comment |
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).
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f183315%2fgenerate-an-rgb-colour-grid%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
VGMwgoDNG