  Gratings and holograms are patterned surfaces that tailor optical signals by
diffraction. Despite their long history, variants with remarkable
functionalities continue to be discovered. Further advances could exploit
Fourier optics, which specifies the surface pattern that generates a desired
diffracted output through its Fourier transform. To shape the optical
wavefront, the ideal surface profile should contain a precise sum of sinusoidal
waves, each with a well-defined amplitude, spatial frequency, and phase.
However, because fabrication techniques typically yield profiles with at most a
few depth levels, complex 'wavy' surfaces cannot be obtained, limiting the
straightforward mathematical design and implementation of sophisticated
diffractive optics. Here we present a simple yet powerful approach to eliminate
this design-fabrication mismatch by demonstrating optical surfaces that contain
an arbitrary number of specified sinusoids. We combine thermal scanning-probe
lithography and templating to create periodic and aperiodic surface patterns
with continuous depth control and sub-wavelength spatial resolution.
Multicomponent linear gratings allow precise manipulation of electromagnetic
signals through Fourier-spectrum engineering. Consequently, we immediately
resolve an important problem in photonics by creating a single-layer grating
that simultaneously couples red, green, and blue light at the same angle of
incidence. More broadly, we analytically design and accurately replicate
intricate two-dimensional moir\'e patterns, quasicrystals, and holograms,
demonstrating a variety of previously impossible diffractive surfaces.
Therefore, this approach provides instant benefit for optical devices
(biosensors, lasers, metasurfaces, and modulators) and emerging topics in
photonics (topological structures, transformation optics, and valleytronics).
