Extendify the ASCII Sun

Write a program that takes in (via STDIN/command line) a non-negative integer N.

When N is 0, your program should print O (that's capital Oh, not zero).

When N is 1, your program should print

\|/
-O-
/|\


When N is 2 your program should print

\ | /
\|/
--O--
/|\
/ | \


When N is 3 your program should print

\  |  /
\ | /
\|/
---O---
/|\
/ | \
/  |  \


For larger N, this pattern continues on in the same exact fashion. Each of the eight rays of the "sun" should be made of N of the appropriate -, |, /, or \ characters.

Details

• Instead of a program, you may write a function that takes an integer. The function should print the sun design normally or return it as a string.

• You must either

• have no trailing spaces at all, or
• only have enough trailing spaces so the pattern is a perfect (2N+1)*(2N+1) rectangle.
• The output for any or all N may optionally have a trailing newline.

Scoring

The shortest code in bytes wins.

• Is a leading newline allowed? Especially interesting for N=0. May 7, 2015 at 23:10
• @Jakube No. Trailing only. May 7, 2015 at 23:12

JavaScript (ES6), 142140134 117 bytes

n=>(g=x=>x?${t= [r=repeat](n-x--)}\${s= [r](x)}|{s}/{t} +g(x):-[r](n))(n)+O+[...g(n)].reverse().join  Try It f= n=>(g=x=>x?{t= [r=repeat](n-x--)}\${s= [r](x)}|${s}/${t} +g(x):-[r](n))(n)+O+[...g(n)].reverse().join i.addEventListener("input",_=>o.innerText=f(+i.value)) o.innerText=f(i.value=1) <input id=i type=number><pre id=o> Powershell, 10897 93 bytes filter f{try{$s=' '*--$_ "$s|s/" _|f|%{(" _ ","-_-")[_-match'O']} "/s|s\"}catch{'O'}}  Explanation: • the recursive algorithm throws an exception on s=' '*--_ when current number less then 1; • the output is a perfect rectangle with trailing spaces. Less golfed test script: filter f{ try{ s=' '*--_ "$s|$s/"
$_|f|%{("$_ ","-$_-")[$_-match'O']}
"/$s|$s\"
}catch{
'O'
}
}

@(

,(0,"O")
,(1,"\|/",
"-O-",
"/|\")
,(2,"\ | /",
" \|/ ",
"--O--",
" /|\ ",
"/ | \")
,(3,"\  |  /",
" \ | / ",
"  \|/  ",
"---O---",
"  /|\  ",
" / | \ ",
"/  |  \")

) | % {
$n,$expected = $_$result = $n|f "$result"-eq"$expected"$result
}


Output:

True
O
True
\|/
-O-
/|\
True
\ | /
\|/
--O--
/|\
/ | \
True
\  |  /
\ | /
\|/
---O---
/|\
/ | \
/  |  \


Charcoal, 12 5 bytes

Ｐ*⊕θO


-7 bytes thanks to @ASCII-only, by using the builtin :*.

Explanation:

Print the 8-armed lines with a length of the input+1 (the +1 is because the center is included), without moving the cursor position:

MultiPrint(:*, Incremented(q));
Ｐ*⊕θ


Then print the "O" at the current location (still in the center, because we haven't moved due to the MultiPrint):

Print("O");
O

• 5? Jan 26, 2019 at 23:44
• @ASCII-only Thanks! Didn't even knew there was a :* builtin for this. Jan 27, 2019 at 12:01

Groovy - 113

f={n->s=2*n+1;(1..s).each{r->(1..s+1).each{c->print c==r?n+1==r?"O":"\\":c==s-r+1?"/":c==n+1?"|":c>s?"\n":" "}}}


I think the ternary logic could probably be cleaned up to give a shorter answer...

SmileBASIC, 87 bytes

INPUT N
FOR Y=-N TO N
FOR X=-N TO N?" \/|-     O"[(X==Y)+!(X+Y)*2+!X*3+!Y*4];
NEXT?NEXT


Canvas, 14 bytes

╵⌐|＊⁸／＋↔ω↶ｎ┼O╋


Try it here!

Retina 0.8.2, 99 bytes

.+
$* X$&$*- ( *)X(-+)$1\|/¶$2X$2¶$1/|\ +^ ( *.)( *)$1$2 |$2/¶$& + ( */)( *).+$
$&¶$1$2 |$2\


Try it online! Explanation:

.+
$* X$&$*-  Place the X and draw n -s to its right. This completes the output for n=0.  ( *)X(-+)$1\|/¶$2X$2¶$1/|\  If n>0 then copy the -s to the left, and add the first level of \|/ and /|\ around the X. This completes the output for n=1. +^ ( *.)( *)$1$2 |$2/¶$&  Extend the \|/ upwards, removing a space of indent each time, adding it back on each side of the |. + ( */)( *).+$
$&¶$1$2 |$2\


Extend the /|\ downwards, removing a space of indent each time, adding it back on each side of the |.

Vyxal, 46 bytes

(\\n›↳⁰↲\|\/n›↲⁰↳Ṡ,)\O-?-,(\/n›↲⁰↳\|\\n›↳⁰↲Ṡ,)


Try it Online!

A mess that I can't be bothered fixing, at least for now.

Japt, 26 25 bytes

Pub golfing so, as usual, could probably be shorter.

Æ"\\|/"¬qXçÃÔp'OiUç-¹·ê û


Try it

Æ"\\|/"¬qXçÃÔp'OiUç-¹·ê û     :Implicit input of integer U
Æ                             :Map each X in the range [0,U)
"\\|/"¬                      :  Split the string "\|/"
q                     :  Join with
Xç                   :    X spaces
Ã                  :End map
Ô                 :Reverse
p                :Push
'Oi             :  "O" prepended with
Uç-          :    "-" repeated U times
¹         :End push
·        :Join with newlines
ê       :Palindromise
û     :Centre pad each line with spaces to the length of the longest