g | x | w | all
Bytes Lang Time Link
130AWK250910T161129Zxrs
038MATL230301T231319ZLuis Men
032Vyxal J220423T191601ZnaffetS
066Perl 5 + pl220412T083326ZDom Hast
037MathGolf220412T074531ZKevin Cr
137C GCC220322T145448Zmatteo_c
095Excel220322T203410ZEngineer
134Rust220322T165342ZSylveste
077JavaScript Node.js220322T095845Zophact
019Charcoal220322T110928ZNeil
069Python220322T075919Zpxeger
042Retina220322T094746ZNeil
058APL+WIN220322T082005ZGraham
121Java 11220322T080523ZKevin Cr
02905AB1E legacy220322T074801ZKevin Cr
081Python 2220322T075715Zovs

AWK, 130 bytes

{for(;i++<$0^2+$0+2;print"")for(j=0;j++<y=$0+2;)printf 1~i&&1~j||1~i&&j~y||i~y&&1~j||i~y&&j~y?"/":1~i?"-":(1~j||j~y)&&i<y?"|":"."}

Attempt This Online!

First attempt:

140 bytes

{for(s="/";i++<x=$0;)s=s"-"
for(s=s"/"RS;j++<x;)u=u"."
for(;k++<x;)s=s"|"u"|"RS
for(s=s"/"u"/"RS;m++<x+2;)w=w"."
for(;l++<x^2;)s=s w RS}$0=s

MATL, 38 bytes

QQttGU+&O46+47blht&(45G:Q(!'|'5MlOh&(c

Try it online!

Vyxal J, 32 bytes

¤-\/pǏD£‛/-‛|.Ŀ⁰Ḋ¥:g\.VDg\/$V⁰²Ḋ

Try it Online!

How?

¤-\/pǏD£‛/-‛|.Ŀ⁰Ḋ¥:g\.VDg\/$V⁰²Ḋ
¤                                # Push an empty string
 -                               # Push "-" * a + b (where a is the (implicit) input, and b is the empty string)
  \/p                            # Prepend "/"
     Ǐ                           # Append its first character (the slash)
      D                          # Triplicate
       £                         # Pop and store in the register
        ‛/-                      # Push string "/-"
           ‛|.                   # Push string "|." (for input 3, stack e.g. ["/---/", "/---/", "/-", "|."])
              Ŀ                  # Transliterate (stack e.g. ["/---/", "|...|"])
               ⁰Ḋ                # Duplicate the top value of the stack the input amount of times (stack e.g. ["/---/", "|...|", "|...|", "|...|"])
                 ¥               # Push contents of register (stack e.g. ["/---/", "|...|", "|...|", "|...|", "/---/"])
                  :              # Duplicate (stack e.g. ["/---/", "|...|", "|...|", "|...|", "/---/", "/---/"])
                   g             # Take the minimum by character code, which is "-" (stack e.g. ["/---/", "|...|", "|...|", "|...|", "/---/", "-"])
                    \.V          # Replace with a period (stack e.g. ["/---/", "|...|", "|...|", "|...|", "/.../"])
                       D         # Triplicate (stack e.g. ["/---/", "|...|", "|...|", "|...|", "/.../", "/.../", "/.../"])
                        g        # Take the minimum by character code, which is "." (stack e.g. ["/---/", "|...|", "|...|", "|...|", "/.../", "/.../", "."])
                         \/      # Push "/"
                           $     # Swap with the period (stack e.g. ["/---/", "|...|", "|...|", "|...|", "/.../", "/.../", "/", "."])
                            V    # Replace (stack e.g. ["/---/", "|...|", "|...|", "|...|", "/.../", "....."])
                             ⁰²  # Push the input squared
                               Ḋ # Duplicate the top value of the stack that many times
                                 # J flag joins the stack by newlines

Perl 5 + -pl, 66 bytes

$;=c x$_;$_=a."-"x$_.ad."b$;bd"x$_.a.$;.a."dcc$;"x$_**2;y;a-d;/|..

Try it online!

Explanation

Generates the output, char by char, replacing characters used multiple times with bareword letters to avoid additional quotes or brackets. Makes use of operator precedence in that x**y works without quotes, but x*x doesn't. Also makes use of the fact that -p adds ;} to the code and uses ; as the separator for y///, saving another byte.

MathGolf, 37 bytes

'.*'|▌'|+k(Ä_'-k*'/▌'/+_¬'.k⌠*k²(Ä_]n

Try it online.

Explanation:

'.*    '# Push a string with the (implicit) input amount of "."
'|▌    '# Prepend "|"
'|+    '# Append "|"
k(Ä     # Loop the input-1 amount of times,
        # using a single character as inner code-block:
   _    #  Duplicate the "|...|" string
'-k*   '# Push a string with the input amount of "-"
'/▌'/+  # Surround it with leading "/"
_       # Duplicate it
 ¬      # Rotate the items on the entire stack once
'.k⌠*  '# Push a string with the input+2 amount of "."
k²(Ä    # Loop input²-1 amount of times,
        #  using a single character as inner code-block:
    _   #  Duplicate the "." string
]       # Wrap the stack into a list
 n      # Join this list with newline delimiter
        # (after which the entire stack is output implicitly)

C (GCC), 143 137 bytes

saved 6 bytes thanks to @ceilingcat

j;main(n){scanf("%d",&n);char s[n+=2];for(;j<n;puts(s))memset(s,46-!j,n),*s=s[n-1]="/|"[j++&&j^n];*s=s[--n]=46;for(j=--n*n;j--;)puts(s);}

Try it online!

Indented version:

j;
main(n){
    scanf("%d",&n);
    char s[n+=2];
    for(;j<n;puts(s))
        memset(s,46-!j,n),
        *s=s[n-1]="/|"[j++&&j^n];
    *s=s[--n]=46;for(j=--n*n;j--;)puts(s);
}

Excel, 96 95 bytes

=LET(r,REPT(".",A1),"/"&REPT("-",A1)&"/"&REPT("
|"&r&"|",A1)&"
/"&r&"/
"&REPT("."&r&".
",A1^2))

Screenshot

Rust, 140 134 bytes

|i|{let r=".".repeat(i);print!("/{}/
{}/{}/
{}
","-".repeat(i),format!("|{}|
",r).repeat(i),r,(".".repeat(i+2)+"
").repeat(i.pow(2)))}

Try it online!

To 134 bytes: I was able to save 6 bytes by using type hinting.

The link includes a header and a footer for calling the closure, and I call it for 1, 2, and 3, to prove that it works!

JavaScript (Node.js), 77 bytes

n=>`/${(C=D=>D.repeat(n))('-')}/
${C(`|${a=C('.')}|
`)}/${a}/
`+C(C(a+`..
`))

Try it online!

Constructs a large template string using a function C to shorten the usage of repeat.

Thanks @Arnauld for -4 bytes by reminding me that literal linefeeds exist. (I've been doing way too much Python recently.)

Charcoal, 19 bytes

Nθ↶UB.×.×θθ/F³«θ↶²/

Try it online! Link is to verbose version of code. Explanation:

Nθ

Input n.

Change the default drawing direction to up. (I do it here because I can use the default pivot of 90°.)

UB.

Set the default character for unpainted areas to ..

×.×θθ

Draw the right-hand edge of the overflowing sand. (The rest of the sand gets drawn as part of the unpainted area.)

/

Draw the bottom right /.

F³«

Repeat three times.

θ

Draw the right |s, the top -s or the left |s as appropriate.

↶²

Pivot the default drawing direction by another 90°.

/

Draw the top right, top left or bottom right / as appropriate.

Python, 69 bytes

lambda n:[f"/{'-'*n}/",*n*[f"|{(c:='.'*n)}|"],f"/{c}/",*n*n*[c+'..']]

Attempt This Online!

-2 bytes thanks to @ophact.

Outputs a list of lines, as allowed by standard I/O rules.

Retina, 42 bytes

.+
/$&*-/¶$&*$(|$&*.|¶)/$&*./$&**$(¶.$&*..

Try it online! Link includes test cases. Explanation: Straightforward application of Retina 1's string repeat operator, except that ** is shorthand for *$&* thus squaring the input.

APL+WIN, 58 bytes

Prompts for n

o,(⍉(n,⍴c)⍴c←'-',((n+1)+n*2)⍴'.'),o←(1,n,1,(n←⎕)*2)/'/|/.'

Try it online! Thanks to Dyalog Classic

Java 11, 121 bytes

n->"/"+"-".repeat(n)+"/\n"+("|"+".".repeat(n)+"|\n").repeat(n)+"/"+".".repeat(n)+"/\n"+(".".repeat(n+2)+"\n").repeat(n*n)

Try it online.

Straight-forward approach using Java 11+'s String#repeat.

05AB1E (legacy), 30 29 bytes

'-×'/.ø©Ð„|.‡I.D®W'.:ÐW‡In.D»

Uses the legacy version of 05AB1E because it can take the minimum character of a string (based on its unicode value), saving 2 bytes over repushing the characters.

Try it online or verify all test cases.

Explanation:

'-×      '# Repeat "-" the (implicit) input amount of times as string
   '/.ø  '# Surround it with leading/trailing "/"
       ©  # Store this string in variable `®` (without popping)
Ð         # Triplicate it
 „|.‡     # Transliterate the "/" to "|" and "-" to "." in the other copy (the
          # transliterate ignores the trailing "…---/" since the strings are
          # of unequal length)
     I.D  # Duplicate it the input amount of times
®         # Push string `®`
 W        # Push the minimum (without popping): "-"
  '.:    '# Replace all "-" with "." in string `®`
Ð         # Triplicate it
 W        # Push the minimum (without popping): "."
  ‡       # Replace all "/" with "." (transliterate again ignores the trailing
          # "…---/")
   In     # Push the input, and square it
     .D   # Duplicate this string of "."s that many times
»         # Join all strings on the stack by newlines
          # (after which the result is output implicitly)

Python 2, 81 bytes

n=input()
i=2
while~n*n<i:i-=1;d='/.|'[~-i*(i+n)and~(i<-n)];print d+'-.'[i<1]*n+d

Try it online!