[Question]
  [
Input a String and surround it with a rounded rectangle of alternating "friendliness pellets".(`0`)
[Sandbox](https://codegolf.meta.stackexchange.com/a/19190/80214)
[![enter image description here](https://i.stack.imgur.com/iGnOL.jpg)](https://i.stack.imgur.com/iGnOL.jpg)
Idea originally from [Lyxal.](https://codegolf.stackexchange.com/users/78850/lyxal)
# Challenge
Given a single line non-empty String of length \$<100\$, print the string with a rounded rectangle of alternating pellets(`0`) around it.
The rectangle must be 11 lines in height.
The first line of the rectangle *must* have at least 1 pellet.
The middle line of the rectangle must be at least 13 characters long. There must be a padding of one space on each side of the text.
Strings smaller than 9 characters must be padded with spaces equally on both sides to fit the above specification.
The right side is allowed to have one extra space if the string is of even length.
The template for the output is as follows:
```
      00000..... 6 spaces
    0 4 spaces 
  0   2 spaces
 0    1 space
0     no spaces
```
If the string's length is greater than or equal to 9; the first line must have \$\text{length}-8\$ pellets.
# Example Input and Output
**Input**:
> 
> Hello World!
> 
> 
> 
**Output**:
```
       0000  
     0      0  
   0          0
  0            0
 0              0
 0 Hello World! 0
 0              0
  0            0
   0          0
     0      0
       0000
```
**Input**
> 
> 0
> 
> 
> 
**Output**
```
       0
     0   0  
   0       0
  0         0
 0           0
 0     0     0
 0           0
  0         0
   0       0
     0   0
       0
```
**Input**
> 
> The quick brown fox
> 
> 
> 
**Output**
```
       00000000000 
     0             0  
   0                 0
  0                   0
 0                     0
 0 the quick brown fox 0
 0                     0
  0                   0
   0                 0
     0             0
       00000000000
```
**Input**
> 
> In this world, it's KILL or BE killed
> 
> 
> 
**Output**
```
      00000000000000000000000000000
    0                               0
  0                                   0
 0                                     0
0                                       0
0 In this world, it's KILL or BE killed 0
0                                       0
 0                                     0
  0                                   0
    0                               0
      00000000000000000000000000000
```
**Input**
> 
> hi there
> 
> 
> 
**Output**
```
      0
    0   0
  0       0
 0         0
0           0
0 hi there  0
0           0
 0         0
  0       0
    0   0
      0
```
# Example code in Ruby
[Try it online!](https://tio.run/##vVLLTsMwELz7K4bkkvQR2goQqIQzf8ABcXCTTWtpa0e2C6oQ3x6cBxBy5IAPlj2zj9nR2tPu3DQyf75abBbrxeoFMVwtCwKT3vsDvEFhSXpCoWzBJITzNt@Td1lxMMd6Kxg5Apb1CVsRo7ZKe1TKOg9WmmAq1MQckkTPRYhmN0JV4Pv8Dv5AGvXJO0SrCMSOvn@zhJe3KUiXAuGE4korrySjlt6T1aIyFjqgkCgNuqifHhrzUGTePpPrpU5/0xgETJL6li33MFCdmK8aXUkhRpJK5WqW59YFpfd4U8G3zkTXjziZsJeTrNdLTi83aVaxCTPM2/RwD@RmIAtS3KITYxC/h/APtHAQIuKJLdidPCy9knVUjjzKBuxfvRpZxXLYicTJI0G60Zqkf1@OpnkM@2XwZCyXF58)
```
a=[4,2,1,0] # space length to create circle
str=gets.chomp;
l = str.length;
# print first line of pellets
print " "*6
if l<=9 then puts "0" else puts "0"*(l-8) end
    
# initial pattern
for n in a do 
    print " "*n +"0"+" "*(5-n)
    print " " if l<=9
    print " "*(l-8) if l>9
    puts " "*(5-n) +"0"
end
    
# display string with spaces
if l<9 then puts "0"+" "*((11-l)/2).floor + str + " "*((12-l)/2).ceil + "0" else puts "0 #{str} 0" end
#initial pattern but reversed
for n in a.reverse do 
    print " "*n +"0"+" "*(5-n)
    print " " if l<=9
    print " "*(l-8) if l>9
    puts " "*(5-n) +"0"
end
    
# last line(same as first line)
print " "*6
if l<=9 then puts "0" else puts "0"*(l-8) end
```
# Scoring
This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"). Shortest answer in each language wins.
  
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), 40 bytes
```
≔⌈⟦¹⁻Ｌθ⁸⟧η×η0↘↘0→↘00↓00‖ＯＯ←η‖Ｏ↓Ｊ⊘⁻⊖ηＬθ⁵θ
```
[Try it online!](https://tio.run/##fY89C8IwEIZ3f0XtdIEKOgiik@BQpEURwUEcQj2bQD5qkkb/fQxWqy4uufDcc9y9FaOm0lSEsLSW1wpKeueylXCcZEnJVWuhQFU7BleSJTNyii8ji8HWcOVgzyVaYFmSjlMSaak9wnylb2rHa@Z674M69W3@s57aV6NnO7wIrNzGoxG0eRWYF3hx3W2/Qjcd8bqVzV5DToXHM3TZVlgZlKhcJCxG67PG/7TffyWLEHIUQicHbcR5OAgjLx4 "Charcoal – Try It Online") Link is to verbose version of code. Explanation:
```
≔⌈⟦¹⁻Ｌθ⁸⟧η
```
Calculate the number of `0`s in the top row.
```
×η0
```
Print them.
```
↘↘0→↘00↓00
```
Print the remaining `0`s on the right.
```
‖ＯＯ←η
```
Reflect the additional rows of `0`s to the left, by overlapping the top row of `0`s onto itself.
```
‖Ｏ↓
```
Reflect the `0`s downwards overlapping the middle row.
```
Ｊ⊘⁻⊖ηＬθ⁵θ
```
Calculate the position of the text and print it there. This is necessary for short strings but also avoids dealing with a Charcoal bug whereby an overlapped reflection moves the cursor to the wrong place.
[Answer]
# JavaScript (ES6), ~~152 139 134~~ 133 bytes
```
s=>'64210~01246'.replace(/./g,k=>(g=i=>--i?(d=i+~k,d*=L-i+~k,s[k>g&&(L+n>>1)-i]||d&&k^6|d<0&&' ')+g(i):`
`)(L=(n=s.length)>9?n+5:14))
```
[Try it online!](https://tio.run/##bYy9TsMwGEX3PsVHB8cmP02qEIkKuxISEhXZGRCoIXYcY8sudqAMUV89LYwo29U999yP5rsJrVeHIbWOi6mjU6Asqsp1kZ/yYl1WUebFwTStwKtsJRNNGZZUUZamaos5VfFJJ/ya1ulfCi@aSYRwHVvGCpKq13HkCOm3auR3OUIRRCSWWJHNfrEnuKbY0pAZYeXQE3a7tfHNpigJmVpngzMiM07iDi8fhTEOnp03/GpJyOIfzme6oRfw@aVaDe/eHS107mdmtbMw9CrA8fc6ATVEAZ52dQ3Ow/0DaGWM4DNery6e8OKCpjM "JavaScript (Node.js) – Try It Online")
### How?
Given an input string of length \$n\$, we define \$L=\min(14,n+5)\$. This is the width of the rows of the ASCII art, including the linefeed.
For each line, we store the number of leading spaces in \$k\$ and iterate from \$i=L-1\$ to \$i=1\$. We test the sign of \$d=(i-k-1)\times(L-i-k-1)\$ to figure out which character must be drawn.
We always draw a space if \$d\$ is negative and a zero if \$d=0\$. If \$d\$ is positive, we draw a zero if \$k=6\$ (top and bottom borders) or a space otherwise (inner cells). The middle line is a special case where we attempt to get the character from the input string, at the position \$\lfloor (L+n)/2\rfloor-i\$.
For `"Hello World!"`, we have \$n=12\$ and \$L=17\$. This gives:
```
    1      0  
i = 6543210987654321
    ------0++0------  k = 6
    ----0++++++0----  k = 4
    --0++++++++++0--  k = 2
    -0++++++++++++0-  k = 1
    0++++++++++++++0  k = 0
    0+Hello World!+0  k = 0
    0++++++++++++++0  k = 0
    -0++++++++++++0-  k = 1
    --0++++++++++0--  k = 2
    ----0++++++0----  k = 4
    ------0++0------  k = 6
```
### Commented
```
s =>                         // s = input string
'64210~01246'.replace(       // replace in the string '64210~01246'
  /./g, k => (               // each character k:
    g = i =>                 //   g is a recursive function taking a counter i:
      --i ?                  //     decrement i; if it's not 0:
        ( d = i + ~k,        //       d = i - k - 1
          d *= L - i + ~k,   //       d = (i - k - 1) * (L - i - k - 1)
          s[                 //       extract from s:
            k > g &&         //         if k is '~':
            (L + n >> 1) - i //           use floor((L + n) / 2) - i
                             //         otherwise, use false
                             //         (leading to s[false] == undefined)
          ]                  //       end of lookup in s
          ||                 //       if it's undefined:
            d &&             //         use '0' if d = 0
            k ^ 6 | d < 0    //         or k is equal to 6 and d is non-negative
            && ' '           //         otherwise, use a space
        ) + g(i)             //       append the result of a recursive call
      :                      //     else:
        `\n`                 //       append a linefeed and stop the recursion
  )(                         //   initial call to g:
    L = (n = s.length) > 9 ? //     if the length n of s is greater than 9:
      n + 5                  //       define L = n + 5
    :                        //     else:
      14                     //       define L = 14
  )                          //
)                            // end of replace()
```
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), ~~64~~ 54 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
4Å0Îg9‚à8-©;î×šŽüÎSú.B®Éi.ºëº}I11Ig-;1‚à©ú®îð×«0.øª».∊
```
[Try it online](https://tio.run/##AW0Akv9vc2FiaWX//zTDhTDDjmc54oCaw6A4LcKpO8Ouw5fFocW9w7zDjlPDui5Cwq7DiWkuwrrDq8K6fUkxMUlnLTsx4oCaw6DCqcO6wq7DrsOww5fCqzAuw7jCqsK7LuKIiv//SGVsbG8gV29ybGQh) or [verify all test cases](https://tio.run/##yy9OTMpM/V@m5JlXUFpipaBkX6nDpeRfWgLh6fw3OdxqYFCZbvmoYdbhBRa6h1ZaH153ePrRhUf3Ht5zuC/48C49p0PrDndm6h3adXj1oV21lYaGlem61oZg9YdWHt4FlF13eMPh6YdWG@gd3nFo1aHdeo86uv7rHNpm/z9aySM1JydfITy/KCdFUUlHQckARIRkpCoUlmYmZyskFeWX5ymk5VeAhD3zFEoyMosVykGqdRQyS9SLFbw9fXwU8osUnFwVsjNzclJTQAozMoEKU4tSlWIB).
**Explanation:**
```
4Å0                   # Push a list of 4 0s: [0,0,0,0]
   Î                  # Push 0 and the input-string
    g                 # Pop the input, and push its length
     9‚à              # Pair with 9, and pop and push the maximum
        8-            # Subtract 8
          ©           # Store this in variable `®` (without popping)
           ;          # Halve it
            î         # Ceil it
             ×        # Create a string of that many 0s
              š       # Prepend it at the front of the [0,0,0,0]-list
ŽüÎ                   # Push compressed integer 64210
   S                  # Convert it to a list of digits: [6,4,2,1,0]
    ú                 # Pad that many leading spaces to the list of 0s
.B                    # Box it, which adds trailing spaces to each string to equal
                      # their lengths
®Éi                   # If the value `®` is odd:
   .º                 #  Mirror each line with the last character overlapping
  ë                   # Else (it's even instead):
   º                  #  Mirror each line without overlapping
  }                   # Close the if-else statement
I                     # Push the input-string again
 11                   # Push 11
   Ig-                # Subtract the input-length from it
      ;               # Halve it
       1‚à            # Pair with 1, and pop and push the maximum
          ©           # Store it in variable `®` (without popping)
           ú          # Pad that many leading spaces to the input
            ®         # Push `®` again
             î        # Ceil it
              ð×«     # Pad that many trailing spaces
                 0.ø  # Then surround it with leading/trailing 0
                    ª # And append it to the list of strings
»                     # Join the lines by newlines
 .∊                   # And mirror the entire string vertically with overlap
                      # (after which the result is output implicitly)
```
[See this 05AB1E tip of mine (section *How to compress large integers?*)](https://codegolf.stackexchange.com/a/166851/52210) to understand why `ŽüÎ` is `64210`.
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 52 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page)
```
³L>9ȯ
L11_»2⁶ẋŒHṚjµL_⁽|hḤD©Ḥ¤⁶ẋ;W¬1¦Ø0j0ç?Ɱ⁶ẋ®¤;"ŒḄY
```
A full program which prints the result.
**[Try it online!](https://tio.run/##y0rNyan8///QZh87yxPruXwMDeMP7TZ61Ljt4a7uo5M8Hu6clXVoq0/8o8a9NRkPdyxxObQSSB5aAlFgHX5ojeGhZYdnGGQZHF5u/2jjOoj4oXWHllgrHZ30cEdL5P///5U88xRKMjKLFcrzi3JSdBQyS9SLFbw9fXwU8osUnFwVsjNzclJTlAA "Jelly – Try It Online")**
### How?
```
³L>9ȯ - Link 1: unused argument; list of characters, Y
³     - program argument, the given text (same as T in the main Link)
 L    - length
  >9  - greater than nine?
    ȯ - logical OR with Y
 
L11_»2⁶ẋŒHṚjµL_⁽|hḤD©Ḥ¤⁶ẋ;W¬1¦Ø0j0ç?Ɱ⁶ẋ®¤;"ŒḄY - Main Link: list of characters, T
L                                              - length
 11_                                           - 11 - that
    »2                                         - max of that and two
      ⁶ẋ                                       - that many spaces
        ŒH                                     - split in two
          Ṛ                                    - reverse (get longer part on the right)
           j                                   - join with T
            µ                                  - start a new monadic chain - f(X=that)
                      ¤                        - nilad followed by link(s) as a nilad:
               ⁽|h                             -   32105
                  Ḥ                            -   double -> 64210
                   D                           -   digits -> [6,4,2,1,0]
                    ©                          -   store in register
                     Ḥ                         -   double -> [12,8,4,2,0]
             L_                                - length (X) minus that (vectorises)
                       ⁶ẋ                      - that many spaces (vectorises)
                          W                    - wrap X in a list
                         ;                     - concatenate
                           ¬1¦                 - logical NOT first line
                                                   (changing spaces to 0s)
                              Ø0               - [0,0]
                                    Ɱ          - map across the lines with:
                                   ?           -   if...
                                  ç            -   ...condition: call Link 1 f([0,0], line)
                                j              -   ...then: ([0,0]) join with (line)
                                 0             -   ...else a single zero
                                        ¤      - nilad followed by link(s) as a nilad:
                                     ⁶         -   space
                                       ®       -   recall from register -> [6,4,2,1,0]
                                      ẋ        -   repeat (vectorises)
                                         ;"    - zip with concatenation
                                                   (prefix lines with spaces)
                                           ŒḄ  - bounce (reflect top lines to the bottom)
                                             Y - join with newlines
                                               - implicit print
```
[Answer]
# [Python 3](https://docs.python.org/3/), 134 bytes
```
lambda s:'\n'.join(f'{0:{i}}{0**i*s:{"0 "[i<6]}^{max(i*2,len(s)+4,13)-(i*2or 2)}}'+'0'[i+i>10>len(s):]for i in(7,5,3,2,1,0,1,2,3,5,7))
```
[Try it online!](https://tio.run/##VYzNqsIwEEb39ynmuknSRklbf6Coax9AcKFeqJrQ0ZhoWlEJefYaES64GPjmnJnv8mxra4pOzTadrs67QwVNSTaGDI4WDVXEi9JjCF4kCSZN6XsCemucjrfhz5@rB8Uk51oa2rB0yLOC9d/EOshZCCQlgqwxxXkm5p@jcquiRIjdEz7iBc95xkWcPOYRnzDWXRyalioafxn7@d9qhLaWTn7BhdTawso6ffj9EstawvWG@xPsnL0bUPYRffcC "Python 3 – Try It Online")
[Answer]
# [Perl 5](https://www.perl.org/), 155 bytes
```
sub f{$_=pop;substr$r=64210001246=~s,.,$"x$&.($&-6?0 .$"x(11-$&*2).0:0).$/,ger=~s,^.{6}(.),($l=y|||c-9)>0?$&.$1x$l:$&,mger,$l>0?59+5*$l:59-$l/2,$l+9,$_;$r}
```
[Try it online!](https://tio.run/##rVTbTuMwEH3nK2ajUZOAG5yqqdSWlNVKK4GANyQeykUCXIgwcdZORVFbfr04F6qkuJDVrp/mHI9nzpzYSZjkwWqqGJwzlQ4GZ0IySHWowlEwXKnpLUzmeBMmIhlqoFKJMux1Oz6l1O90e@GbIh5Ba4Ytz8FWu3dIwdPQ8f02tnY7rkcH1PVwnzwwmSVfe/Pe0vFc4iAPXxeLxV27747ooT6P/gz5AFvkWecS5JoN@nvBriaDfhv5fkeTe32CN0OUy9VESGdsHzHOBVwIye9/2BCO4ODAtq/IDuRLq6R5SEu8sw5LWEEZrsGCqHYwZWyW2OxQ775WlcdjmxpEr89Ui9Ua1WV8IGrcqx2r1at0KZhSU/rI4M80unuCWyleYpiImdnaclVnNNuwxaxttld4g5Yv8reU36LFqHpztsIT6zjWUiIFL9k9IBCltoKT49NTEBJ@/YaniHN2b33l0udlUNBUfePhm7ttzmw091/VbCyz8dwNXfz@e5T3/zHKrp1k/@lpfpT7t6fpzvP4@dXBKE4Islnihj/1v7CkAR9EGk7yXbcgExnFKViXcbZ1GVsFGymnpCySBbqQRcpTy9U7 "Perl 5 – Try It Online")
Slightly ungolfed:
```
sub f{
  $_=pop;                           # $_ = input text
  substr                            # args: string, offset, length, replacement
    $r=                             # $r = result string init to empty rectangle
      64210001246                   # digits are spaces before first 0 each line
        =~s,.,$"x$&.($&-6?0 .$"x(11-$&*2).0:0).$/,ger
        =~s,^.{6}(.),($l=y|||c-9)>0?$&.$1x$l:$&,mger,
    $l>0 ? 59+5*$l : 59-$l/2,       # insert input text at this position
    $l+9,                           # ...this length ($l=input length minus 9)
    $_;                             # replacement = input
  $r                                # return result
}
```
[Answer]
# [Python 3.8 (pre-release)](https://docs.python.org/3.8/), 158 bytes
```
lambda s:'\n'.join((e:=[" "*6+"0"*(l:=len(b:=(c:=9-len(s))//2*' '+s+(c//2+c%2)*' ')-8),*[i*" "+"0"+" "*(l+10-2*i)+"0"for i in[4,2,1,0]],f'0 {b} 0'])+e[4::-1])
```
[Try it online!](https://tio.run/##VY3LTsMwEEX3fMVgCfkZ6oQKFUvZICFR0X0XaRZ5OIqpsYMTVBDi29N4g5Td3HNnzgw/U@/dw24Ic5WfZlt91G0Fo8Inh@/fvXGEaJUXCBB75EgiRqzKrXakVjlpVP6UxDBSutlkDAPmIyfNMvPmLqMR0GRHBSsMWxRRwKOKWJ7KJGOGRtT5AAaMK7YiE6mQZSk6LOG3/gOJS8p1sVUqSUs6D8G4iVQEvWprPRx9sO0tovTmv5CrtHcw9WaES1wUYCY8wtv@cIDl4/MLnI21ul1dTL2Gzy/TnKEO/uKg89@rvjeLUQe9wPkK "Python 3.8 (pre-release) – Try It Online")
]