Skip to content

Surface

Hyomoto edited this page Jun 13, 2021 · 18 revisions
Jump To Go Back Arguments Methods Variables

Surface( width, height )

A wrapper for the built-in GML surface type. Provides several quality of life improvements such as automatic recreation of the surface should it goes missing, as well as reduced syntax verbosity. The surface can also be made to only update when requested by the user by using the update function to check if it should be redrawn. The example demonstrates this feature.

if ( surface.update() ) {
	draw_clear( c_white );
}
surface.draw( 0, 0 );
Output: The surface will be cached as white, and drawn

Arguments

Name Type Purpose
width int The width of the surface
height int The height of the surface

Methods

Jump To top resize update redraw draw get set reset free

resize( width, height )

Returns: self

Name Type Purpose
width int The width of the surface
height int The height of the surface

Resizes the internal surface, will also trigger a redraw of the surface. If the provided arguments are not integers, InvalidArgumentType will be thrown.


update( *forced )

Returns: bool

Name Type Purpose
*forced bool optional: Whether to force an update

Returns whether or not this surface needs to be updated. This will return true if the internal surface has not been created, has been freed, redraw is flagged, or forced is set to true.


redraw( )

Returns: self

Name Type Purpose
None

Flags the surface to be redrawn next time update is checked.


draw( x, y )

Returns: self

Name Type Purpose
x real A x position
y real A y position

Draws the surface at the given coordinates.


get( )

Returns: undefined or int

Name Type Purpose
None

If the internal surface exists, returns the id to it. Otherwise, undefined is returned.


set( )

Returns: self

Name Type Purpose
None

The same as calling surface_set_target( surface.get() )


reset( )

Returns: self

Name Type Purpose
None

The same as calling surface_reset_target()


free( )

Returns: self

Name Type Purpose
None

Frees the internal surface. Note, if you attempt to use the surface again it will be recreated.


Variables

Jump To top
Name Type Initial Purpose
__Surface int -1 A pointer to the internal surface
__Redraw bool false when set to true, will trigger a surface redraw on the next frame
width int _width The width of the surface. Changing this will not resize the surface, use resize() instead.
height int _height The height of the surface. Changing this will not resize the surface, use resize() instead.
Clone this wiki locally