Programmable nanoscale domain patterns in multilayers