Name
csurface:CreateForRectangle -- create surface from rectangle
Synopsis
handle = csurface:CreateForRectangle(x, y, width, height)
Function
Create a new surface that is a rectangle within the target surface. All operations drawn to this surface are then clipped and translated onto the target surface. Nothing drawn via this sub-surface outside of its bounds is drawn onto the target surface, making this a useful method for passing constrained child surfaces to library routines that draw directly onto the parent surface, i.e. with no further backend allocations, double buffering or copies.

The semantics of subsurfaces have not been finalized yet unless the rectangle is in full device units, is contained within the extents of the target surface, and the target or subsurface's device transforms are not changed.

This function returns a handle to the newly allocated surface. The caller owns the surface and should call csurface:Free() when done with it.

This function always returns a valid handle, but it will return a handle to a "nil" surface if the source surface is already in an error state or any other error occurs.

Inputs
x
the x-origin of the sub-surface from the top-left of the target surface (in device-space units)
y
the y-origin of the sub-surface from the top-left of the target surface (in device-space units)
width
width of the sub-surface (in device-space units)
height
height of the sub-surface (in device-space units)
Results
handle
handle to a new surface

Show TOC