Output visual diagram of picture Write a program that inputs the dimensions of a painting, the matting width, and the frame width for a framed portrait. The program should output a diagram using the symbol X for the painting, + for the matting, and # for the framing. The symbols must be space-separated. Trailing whitespace is alright, as long as the output visually matches the criteria. The inputs can be 0.

INPUT: 3 2 1 2
(Width, Height, Matte Width, Frame Width)

OUTPUT:  



In text form:

# # # # # # # # #
# # # # # # # # #
# # + + + + + # #
# # + X X X + # #
# # + X X X + # #
# # + + + + + # #
# # # # # # # # #
# # # # # # # # #


The winning code completes the conditions in the least possible bytes.
Python 2, 98 bytes



w,h,a,b=input()
a*='+'
b*='#'
for c in b+a+h*'X'+a+b:print' '.join(min(c,d)for d in b+a+w*'X'+a+b)


Try it online!

Prints a space-separated grid, strictly following the spec. I'm amused that *= is used to convert a and b from numbers to strings.

Python 3 can save some bytes by avoiding ' '.join, maybe more by using f-strings and assignment expressions. Thanks to Jo King for -2 bytes.

Python 3, 93 bytes



def f(w,h,a,b):a*='+';b*='#';[print(*[min(c,d)for d in b+a+w*'X'+a+b])for c in b+a+h*'X'+a+b]


Try it online!