|parrotcode: Parrot class representing colors in Parrot SDL|
|Contents | Libraries|
SDL::Color - Parrot class representing colors in Parrot SDL
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'()
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.
SDL::Color objects have the following methods:
color_args, should be a
PerlHashPMC containing the following keys:
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 (c) 2004, The Perl Foundation.