NAME ^

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

SYNOPSIS ^

    load_bytecode 'library/SDL/Color.pir'

    # create a new SDL::Color object
    .local pmc color
    color = new 'SDL::Color'

    # set the color values; this one's blue
    color.'init'( 'r' => 0, 'g' => 0, 'b' => 255 )

    # 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( 'r' => xxx, 'g' => xxx, 'b' => xxx )

Initialize the new object with the necessary arguments, key-value pairs where:

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.

color()

Returns a PMC 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-2007, The Perl Foundation.


parrot