This is not a very efficient implementation yet, but it seems to work.
Part of the groundwork for gradients.
This is a prerequisite for supporting gradients and images.