# Render a version of the BBC Micro owl logo

Can you render out a version of the BBC Micro Owl logo as per above from code?

Rules:

• You can use any programming language you like.
• Output can be text or graphic.
• Circles don't have to overlap.

Winner:

• The answer with the most upvotes wins.

Kudos for anyone that attempts this in BBC basic.

You can read about the BBC Micro here

• "Most inventive" and "most like the original" is subjective. Please provide an objective winning criterion. (I am voting to close, as per "Questions without an objective primary winning criterion are off-topic, as they make it impossible to indisputably decide which entry should win.") – Doorknob Jan 23 '14 at 13:53
• I have changed the win criteria to the shortest code which I hope is less subjective for everyone. – Ben Paton Jan 23 '14 at 17:16
• Maybe code-golf is fine but I think this question could suit a popularity-contest tag instead. Most votes wins. That's objective. Mob decides. This encourages interesting results without sacrificing output quality/creativity to save a few chars of code. Witness the freestyle Olympic rings question. – Darren Stone Jan 23 '14 at 18:36
• Good idea I have changed it to most upvotes wins which is fairer. How do I get this taken off hold? – Ben Paton Jan 23 '14 at 19:54

# BBC BASIC

I tried using trig functions to draw proper circles, but that was painfully slow. Came up with this instead:

10 MODE 1
20 GCOL 0,1 : VDU 19,1,3,0,0,0
30 FOR Y%=0 TO 20
40 READ N% : P%=65536
50 FOR X%=0 TO 16
60 IF (N% AND P%)=0 THEN GOTO 160
70 X0% = X%*32+384 : Y0% = 872-Y%*32
80 FOR DX%=-16 TO 16 STEP 8
90 FOR DY%=-8 TO 8 STEP 8
100 PLOT 69,X0%+DX%,Y0%+DY%
110 NEXT DY% : NEXT DX%
120 FOR DX%=-8 TO 8 STEP 8
130 FOR DY%=-16 TO 16 STEP 32
140 PLOT 69,X0%+DX%,Y0%+DY%
150 NEXT DY% : NEXT DX%
160 P%=P%/2
170 NEXT : NEXT
1000 DATA 87381,33410,69905,10280
1010 DATA 69649,33410,82181,40968
1020 DATA 87377,43520,87297,43520
1030 DATA 21761,10880,5441,2720
1040 DATA 1361,552,1093,43682,1


Here's the output:

• Wow seriously amazing someone actually took the time to use BBC basic. I'm very impressed!! – Ben Paton Jan 24 '14 at 12:21
• That's a nice owl. Are you using a real BBC or an emulator program. If it's an emulator, which one? cos it's not the same as the one I used. – Level River St Feb 8 '14 at 21:29
• BTW, if you want to draw circles quicker, don't use trig functions, use pythagoras theorem: Y=(R^2-X^2)^0.5 see my answer to the rainbow question. And there's actually a more advanced way of doing it with only addition, based on the fact that (1)+(3)+(5)....(1+2n) = (n+1)^2. – Level River St Feb 8 '14 at 21:34

### GolfScript

"!C-DD[5v>U8GJ2zX['b#L*\\q>FQp "{32-}%96base 2base{"   *"2/=}%18/{""*1>17/~n@n}/


The code prints an ascii art version of the logo (run here).

* * * * * * * * *
*     * *     *
*   *   *   *   *
* *     * *
*   *       *   *
*     * *     *
* *     *     * *
* *         *
* * * * * * *   *
* * * *
* * * * *       *
* * * *
* * * *       *
* * * *
* * * *     *
* * * *
* * * *   *
*   * *
*   *   * *
* * * * * *   *
*

• Really impressive in 82 characters! – Ben Paton Jan 23 '14 at 17:19

# Mathematica

Nothing but grunt work.

w = 20; h = 25; r = .7; r2 = .2; t = Table; d = Disk;
owl = Graphics[{Polygon[{{0, 0}, {w, 0}, {w, h}, {0, h}}],
ColorData[57, 4],
t[d[{k, 22}, r], {k, 2, 19, 2}],
t[d[{18, k}, r], {k, 2, 21, 2}],
t[d[{k, #}, r], {k, #2}] & @@@ {{21, {3, 9, 10, 11, 17}}, {20, {2,
6, 10, 14, 18}},
{19, {5, 6, 7, 13, 14, 15}}, {18, {6, 9, 11, 14}}, {17, {10,
17}, {16, {16}}, {15, {15}}, {14, {8, 10, 12, 14}},
{13, {9}}, {12, {9}}}},
t[d[{# - k, k}, r], #2] & @@@ {{20, {k, 18, 3, -1}}, {19, {k, 16,
6, -1}}, {18, {k, 16, 5, -1}}, {17, {k, 14, 7, -1}}, {16, {k,
14, 6, -1}}, {14, {k, 11, 5, -1}}, {14, {k, 12, 5, -1}}},
t[d[{k, 4}, r], {k, {8, 12}}],
t[d[{k, 3}, r], {k, 3, 13, 2}],
d[{8, 13}, r],
Black, d[{10, 21}, r2], d[{8, 13}, r2], d[{9, 12}, r2],
t[d[{19 - k, k}, r2], {k, 16, 6, -1}],
t[d[{17 - k, k}, r2], {k, 14, 7, -1}],
t[d[{15 - k, k}, r2], {k, 12, 6, -1}],
t[d[{k, 19}, r2], {k, {6, 14}}]}, ImageSize -> 220]


### R

image(t(matrix(as.integer(sapply(c(1397760,567810,1070336,141954,1381696,133794,
1054036,559786,1332560,557218,1052756,131114,
1380368,139272,1064964,557058,1398101),
intToBits)[1:21,]),nr=21)),ax=F)


Results in:

Basically the idea is to take the base-2 representation of the 17 numbers (1397760, 567810, 1070336, 141954, 1381696, 133794, 1054036, 559786, 1332560, 557218, 1052756, 131114, 1380368, 139272, 1064964, 557058 and 1398101), make it into a 21x17 matrix of 1 and 0s and plot the matrix as is.

# Pov-Ray

background{color<.14,.01,.01>}
camera{orthographic location z*-2 up y*24 right x*20}
#macro s(X,Y)sphere{<X,Y,0>,1.07,2.6}#end
#declare b=array[17]{1397760,567810,1070336,141954,1381696,133794,1054036,
559786,1332560,557218,1052756,131114,1380368,139272,1064964,557058,1398101}
blob{threshold 0.9 #for(j,0,16,1)#declare V=b[j];#for(i,0,28,1)
#if(mod(V,2))s(j-8,i-10)#end #declare V=floor(V/2);#end #end
pigment{color<1,1,.8>}finish{ambient 1}}


'compile' with povray +Ibbc.pov -Obbc.png +A0.1 +R9 -W240 -H285

## Bash

Since you didn't specify no external resources...

curl -s http://codegolf.stackexchange.com/questions/19214/render-a-version-of-the-bbc-micro-owl-logo | grep '* * *' | sed -n '/code>\*/,/<pre>/p' | sed '$d' | sed 's/<pre><code>//'  Howard - stole your Ascii art, thanks. Or after I uploaded it here - curl -s http://textuploader.com/1ojd | sed -n '/<code/,/<\/code>/p' | sed 's/<[^>]\+>//g'  • Well that's lateral thinking I suppose... – Ben Paton Jan 24 '14 at 23:29 # BBC Basic, random colours, golfed! 149 characters. I'm not that big on golfing (I prefer the code challenges) but I liked the ridiculousness of golfing in BBC basic. BBC emulator at http://www.bbcbasic.co.uk/. Runs in screen mode 6 at the command line. FORK=6TO185S=K MOD9=5VDU-32*(K MOD18=15),17,128+RND(6)*(ASCMID$("?OSUuLEMSS^H?=A_W",K/6,1)/2^(K MOD6)AND1),32,17,128,32,-13*S,-10*S:NEXT

Explanation (ungolfed version)

No IF statements, because the rest of the line would only be executed if the IF was true (so to ensure the NEXT was reached I would have to do a program with line numbers.) Therefore I made a lot of use of ASC(null character)=0 to control output. Also, I had to cut off the pixel at the bottom right corner to fit the whole command line on the screen after printing (and that saved 2 characters.

I love how BBC basic can recognise an identifier after FOR, even with no white space. FORE, FORD, FORK, FORM, FORS, FORT :-)

 FOR K=6 TO 185

REM Set S to true(-1) if K mod 9 = 5, otherwise set S to false(0)

S = K MOD 9=5

REM If K mod 18 = 15, send asc(space)=32 to the VDU controller,otherwise send 0.
REM This causes staggering every 2 lines.

VDU-32*(K MOD18=15)

REM Vdu 17 for colour. foreground colours start at 0, background colours at 128.
REM Rnd(6) to choose a bright color. Multiply by the horrible expression.
REM The horrible expression evaluates to 1 if the pixel is to be printed, 0 if not.
REM Picture data is stored in base 64 in the string.
REM MID$extracts the characters in order. REM The FOR loop starts at K=6 so that this will work properly. REM Extracted character SHR ((K mod 6)) AND 1 to decide to REM colour pixel or not. BBC basic does not have SHR operator. REM so we divide by 2^(K mod 6) instead. VDU 17,128+RND(6)* (ASC(MID$( "?OSUuLEMSS^H?=A_<A^tC|dGxEMh>W" ,K/6,1))/2^(K MOD 6)AND 1)

REM Print a space in the new background colour

VDU 32

REM Change background colour back to black

VDU 17,128

REM Print another space

VDU 32

REM If S is true (-1) print a carriage return and linefeed. otherwise two 0's

VDU -13*S,-10*S

NEXT

• Thanks for contributing that's a really clever solution and a nice multicoloured owl, I haven't seen golfed BBC basic before. – Ben Paton Feb 6 '14 at 23:39
• Thank you for inspiring me to go and look for a BBC basic emulator. It's a great language that I haven't used in 20 years. It's got a lot of graphics facilities built in without having to include add-on libraries, which makes it an excellent language for golfing a task like this. – Level River St Feb 7 '14 at 20:13
• Also, first time I've used base 64. It was just right for this image, being 18 pixels for each 2 lines. I will definitely use it again. The fact that the 6th bit is uppercase/lowercase means you only really have to think about the other five. I found that made it almost as easy as hex once I got into it. – Level River St Feb 7 '14 at 20:23

## C

ASCII output.

x[]={256,191,424,104,376,60,316,30,286,15,287,15,383,67,403,153,325,102,341,153,511};i=20;mai
n(){for(;i>=0;i--){i&1&&putchar(32);while(x[i]){putchar(x[i]&1?42:32);x[i]>>=1;putchar(32);}pu
tchar(10);}}


Code output:

* * * * * * * * *
*     * *     *
*   *   *   *   *
* *     * *
*   *       *   *
*     * *     *
* *     *     * *
* *         *
* * * * * * *   *
* * * *
* * * * *       *
* * * *
* * * *       *
* * * *
* * * *     *
* * * *
* * * *   *
*   * *
*   *   * *
* * * * * *   *
*


# JavaScript - 326307 285 characters (ASCII)

a=[1716886015,1133746501,253693823,1010572830,3215485048,0];s="";with(Math)
for(y=0;44>y;y++,s+="\n")for(x=0;90>x;x++,s+="#8*+=:-. "[min(floor(d),8)])
for(j=d=0;22>j;j++)for(i=0;9>i;i++)1==((8==i?j+1:a[floor(j/4)]>>i+j%4*8)&1)
&&(d+=50/pow(pow(x-10*(i+j%2/2)-4,2)+pow(2*y-4*j-4,2),1.5));s;


Probably not the shortest code. I tried to be as close as possible to the original logo, using only ASCII.

To execute : copy paste to javascript console (eg: chrome or firefox). Note : the script might take a little time to run so if nothing come just after pressing enter, be a little patient.

• You can shorten this by doing m=Math; and then doing m.floor, m.pow etc. – eithed Jan 24 '14 at 10:27
• Even moreso by wrapping the outermost for-loop in a with (Math) and then omitting Math. at each occurence. Move the s+= parts to the for-loop header (next to y++/x++) to get rid of some braces. I think it's typical to use alert/prompt for I/O when golfing in JS, so I'd go with alert(s) at the end instead. – FireFly Jan 24 '14 at 10:54
• Thanks for tips and comments. I am a beginner when it comes to code size optimizing :) About alert / prompt suggestion : I tried to use them, but there is some issues : browsers (chrome at least) seems to automatically wrap text if line is too long, which broke logo. – tigrou Jan 24 '14 at 13:47

# CoffeeScript

Code isn't golfed. It uses some metaballs-ish algorithm to simulate "stickyness" of the circles. ASCII owl was shamelessly stolen from other answers :)

canvas = document.createElement 'canvas'
canvas.style.backgroundColor = '#240202'
canvas.style.transform = 'scale(0.5) translate(-480px,-570px)'
W = canvas.width = 960
H = canvas.height = 1140
D = 50
R = D / 2
ctx = canvas.getContext '2d'
imageData = ctx.getImageData 0, 0, W, H
data = imageData.data
owl = '''

\ * * * * * * * * *
\  *     * *     *
\ *   *   *   *   *
\    * *     * *
\ *   *       *   *
\  *     * *     *
\ * *     *     * *
\  * *         *
\ * * * * * * *   *
\  * * * *
\ * * * * *       *
\  * * * *
\   * * * *       *
\    * * * *
\     * * * *     *
\      * * * *
\       * * * *   *
\        *   * *
\       *   *   * *
\  * * * * * *   *
\                 *
'''.split '\n'

insideDot = (x, y) ->
w = 0
for du in [-1..1] then for dv in [-1..1]
u = x // D + du
v = y // D + dv
continue unless owl[v]?[u] is '*'
dx = x - (u * D + R)
dy = y - (v * D + R)
d = dx * dx + dy * dy
w += 1 / (d * d)
return yes if w > 0.0000008
no

for y in [0...H] then for x in [0...W] when insideDot x, y
i = (y * W + x) * 4
data[i] = data[i+1] = data[i+3] = 255
data[i+2] = 214

ctx.putImageData imageData, 0, 0
document.body.appendChild canvas


Watch it destroy the coffeescript.org documentation (hit Run):

PHP

Building upon the ascii art versions of the logo submitted previously and using this as the array to render a graphical version using the GD library.

$circleWidth = 34;$circleHeight = 34;
$movement = 24;$canvasWidth = 480;
$canvasHeight = 570;$image = imagecreatetruecolor($canvasWidth,$canvasHeight);
$backgroundColour = imagecolorallocate($image, 36, 2, 2);
ImageFillToBorder($image, 0, 0,$backgroundColour, $backgroundColour);$circleColour = imagecolorallocate($image, 255, 255, 214);$coordinates ='
* * * * * * * * *
*     * *     *
*   *   *   *   *
* *     * *
*   *       *   *
*     * *     *
* *     *     * *
* *         *
* * * * * * *   *
* * * *
* * * * *       *
* * * *
* * * *       *
* * * *
* * * *     *
* * * *
* * * *   *
*   * *
*   *   * *
* * * * * *   *
* ';
$coordinates = str_split($coordinates);
$coordinateX =$movement;
$coordinatY =$movement;
$i=1; foreach ($coordinates as $coordinate) { if ($i < 19) {
if ($coordinate == '*') { ImageFilledEllipse($image, $coordinateX,$coordinatY, $circleWidth,$circleHeight, $circleColour); }$coordinateX = $coordinateX +$movement;
$i++; } else {$i=1;
$coordinateX =$movement;
$coordinatY =$coordinatY + $movement; } } header("Content-type: image/png"); imagepng($image);
imagedestroy(\$image);


Results in: