Apparatus and method for defining a pattern on a substrate