pat = cairo.PatternForSurface(surface)
This function returns the newly created Cairo pattern if successful, or an error pattern in case of no memory. The caller owns the returned object and should call cpattern:Free() when finished with it.
This function will always return a valid handle, but if an error occurred the pattern status will be set to an error. To inspect the status of a pattern use cpattern:Status().