#JavaScript (ES6), 139 135 140 + 1 bytes
(+1 is for -p
flag with node in the console)
fixed:
t=(n,m)=>(m=2*n+1,(A=Array).from(A(m),(d,i)=>A.from(A(m),(e,j)=>i==j?j==n?"O":"\\":m-1==j+i?"/":i==n?"-":j==n?"|":" ").join("")).join("\n"))
usage:
t(3)
/*
\ | /
\ | /
\|/
---O---
/|\
/ | \
/ | \
*/
ungolfed:
var makeSun = function (n, m) {
m = 2 * n + 1; // there are 2*n+1 in each row/column
return Array.from(Array(m), function (d, i) {
return Array.from(Array(m), function (e, j) {
// if i is j, we want to return a \
// unless we're at the middle element
// in which case we return the sun ("O")
if (i == j) {
return j == n ? "O" : "\\";
// the other diagonal is when m-1 is j+i
// so return a forward slash, /
} else if (m - 1 == j + i) {
return "/";
// the middle row is all dashes
} else if (i == n) {
return "-";
// the middle column is all pipes
} else if (j == n) {
return "|";
// everything else is a space
} else {
return " ";
}
}).join("");
}).join("\n");
}