NAME ^

SDL::Color - Parrot class representing colors in Parrot SDL

SYNOPSIS ^

        load_bytecode 'library/SDL/Color.imc'

        # create a new SDL::Color object
        .local pmc color
        .local int color_type

        find_type color_type, 'SDL::Color'
        color = new color_type

        # set the color values; this one's blue
        .local pmc color_args
        color_args = new PerlHash

        color_args[ 'r' ] =   0
        color_args[ 'g' ] =   0
        color_args[ 'b' ] = 255

        color.'_new'( color_args )

        # fetch the color value to pass directly to SDL functions
        # (you should never need to do this if the rest of the library works right)
        .local int color_value
        color_value = color.'color'()

DESCRIPTION ^

SDL::Color provides a very thin object layer over colors as used in SDL. For the most part, it's just a constructor and a convenient way to pass things around. In the future, it may grow more complex if you do odd things that require depth conversions. They make my head hurt now though.

This object represents a single color of, we'll say, 24-bit depth -- eight bits per red, green, and blue component. This may not match your requirements exactly. Per my understanding of SDL, though, it'll do the conversions for you automatically. Patches welcome.

METHODS ^

SDL::Color objects have the following methods:

_new( color_args )

Initialize the new object with the necessary arguments, The single argument, color_args, should be a PerlHash PMC containing the following keys:

r

An integer from 0 to 255 representing the amount of red in the color, where 0 is none and 255 is the maximum possible.

g

An integer from 0 to 255 representing the amount of green in the color, where 0 is none and 255 is the maximum possible.

b

An integer from 0 to 255 representing the amount of blue in the color, where 0 is none and 255 is the maximum possible.

The name of this method may change, pending better ideas as discussed on p6i.

color()

Returns an integer representing the actual color value passed to the underlying SDL functions. You should never need to use this directly, unless you need to call those functions directly.

color_for_surface( surface )

Returns an integer representing the current color appropriate for the given SDL::Surface surface,

As far as I understand things right now, you don't need to call this directly unless you're manipulating raw pixels and need the boost of speed from preconverting colors. In that case, you probably do need the speed boost.

The name of this method may change.

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