NAME ^

SDL::Rect - Parrot class representing rectangles in Parrot SDL

SYNOPSIS ^

        # load this library
        load_bytecode 'library/SDL/Rect.pir'

        # create a new SDL::Rect object
        .local pmc rect
        .local int rect_type

        find_type rect_type, 'SDL::Rect'
        rect = new rect_type

        # set some arguments for this SDL::Rect
        .local pmc rect_args

        new rect_args, .PerlHash
        rect_args[ 'x'      ] = 270
        rect_args[ 'y'      ] = 190
        rect_args[ 'height' ] = 100
        rect_args[ 'width'  ] = 100

        # now set the arguments on the object
        rect.'_new'( rect_args )

        # ... and blit to or fill surfaces with this object!

DESCRIPTION ^

The SDL::Rect class represents rects in SDL. SDL::Rect objects represent sources and destinations for filling and blitting to and from SDL::Surface objects.

METHODS ^

An SDL::Rect object has the following methods:

_new( rect_args )

Given a PerlHash of arguments, sets the attributes of this object. The hash has the following keys:

x

The x coordinate of this object, in pixels. This represents a position within a SDL::Surface object, but it's an attribute of the rect, not the surface.

y

The y coordinate of this object, in pixels. This represents a position within a SDL::Surface object, but it's an attribute of the rect, not the surface.

height

The height, in pixels, of this object.

width

The width, in pixels, of this object.

The name of this method may change, as per discussion on p6i.

rect()

This method returns the underlying SDL_Rect. You'll probably never need to call this directly, unless you're using raw SDL functions.

height()

Returns the height of this object in pixels. Arguably, this should also set the value.

width()

Returns the width of this object in pixels. Arguably, this should also set the value.

x( [ new_x_coordinate ] )

Gets and sets the x coordinate of this rect. Note that this value is always an integer.

y( [ new_y_coordinate ] )

Gets and sets the y coordinate of this rect. Note that this value is always an integer.

AUTHOR ^

Written and maintained by chromatic, <chromatic at wgz dot org>, with suggestions from Jens Rieks. Please send patches, feedback, and suggestions to the Perl 6 Internals mailing list.

COPYRIGHT ^

Copyright (c) 2004, The Perl Foundation.


parrot