Adding serialization to gradients and patterns