Generate a "GitHub" Avatar

Pyth - 27 bytes

.wC+Kc3O^Cm,240O256 3 15_PK

Obviously doesn't work online, but you can have it print color codes here.


Perl 5, 77 bytes

This is non-competing as it only has a 256 colour palette, only works on terminals that support ANSI escape codes and doesn't actually output a 5 pixel square image, but I thought I'd post it anyway as it was fun golfing this down.

sub x{"\e[48;5;@{[rand>.5?$-||=rand 254:254]}m  "}say$}=x,$b=x,x,$b,$}for 0..4

Note: the \e is actually ASCII char \x1B.

Usage

perl -E 'sub x{"\e[48;5;@{[rand>.5?$-||=rand 254:254]}m  "}say$}=x,$b=x,x,$b,$}for 0..4'

Explanation

Nothing particularly clever except perhaps:

  • Use $- to automatically round the colour number for use in the escape sequence, used instead of $n=0|rand 254.

Example output

Yeah, you'll be stuck with whatever the last colour was, all over your -boink- terminal.


MATL, 36 29 bytes

5l$rtP+!kllII$r*O16tQ/XE'a'YG

This saves the result in file a.png.

Replacing 'a' by 2 in the code displays the image (scaled up) instead of saving a file:

5l$rtP+!kllII$r*O16tQ/XE2YG

Here's an example output:

enter image description here

Explanation

5l$r     % 5×5 matrix of independent random values with uniform distribution
         % on the interval (0,1)
tP+!     % Duplicate, flip vertically, add, transpose. This gives a horizontally
         % symetric matrix. Center column pixels are uniformly distributed on the 
         % interval (0,2). Rest have a triangular distribution on (0,2)
k        % Round down. In either of the above cases, this gives 0 and 1
         % with the same probability
llII$r   % 1×1×3 array of independent random numbers with uniform distribution
         % on (0,1). This is the foreground color.
*        % Multiply the two arrays with broadcast. Gives a 5×5×3 array. Ones in the
         % 5×5 array become the random foreground color. Zeros remain as zeros.
O        % Push 0
16tQ/    % 16, duplicate, add 1, divide: gives 16/17, or 240/255
XE       % Replace 0 by 16/17: background color
'a'      % Push file name
YG       % Write image to that file