It's a Slippery Slope
Jelly, 23 bytes

Ṛ⁹,2⁶v$Ṡ$e⁵$?¥þị“/ \-”Y


Try it online!

Arguments: Y, X, U, f

f is a Python string containing Jelly code. Be sure to quote it appropriately, otherwise you may encounter errors.

Also, f takes a pair [x, y] as its argument, not two arguments x and y.