home *** CD-ROM | disk | FTP | other *** search
/ Acorn User 10 / AU_CD10.iso / Updates / Perl / Non-RPC / Docs / RISCOS-Library-Docs / Colour.pm < prev    next >
Text File  |  1999-04-17  |  2KB  |  51 lines

  1. NAME
  2.     RISCOS::Colour -- conversions between RISC OS colour values and
  3.     arrays
  4.  
  5. SYNOPSIS
  6.         use RISCOS::Units qw(unpack_colour);
  7.         $col = unpack_colour ($packed);
  8.         print "Red = $$col[0]; Green = $$col[1]; $Blue = $$col[2]\n";
  9.  
  10.  
  11. DESCRIPTION
  12.     This module provides conversion functions between arrays of RGB
  13.     values and 32 bit integers used by RISC OS to store colours.
  14.  
  15.     pack_colour <colour>, ...
  16.         `pack_colour' packs integers or arrays of RGB triples into 4
  17.         bytes as used in blocks passed to RISC OS SWIs. `undef' maps
  18.         to -1 ('`ÿÿÿÿ'') which is used in DrawFiles to mean
  19.         transparent, integers are taken to be a single colour of the
  20.         form 0xBBGGRR00, scalar references are assumed to be already
  21.         packed, and array references are assumed to point to 3
  22.         integers (red, green, blue) in the rage 0 - 255. To convert
  23.         a single colour call in scalar conted:
  24.  
  25.             $colour = pack_colour [1, 0, 1];
  26.             # Pack magenta, passing ref to an anonyomous hash
  27.  
  28.  
  29.         To convert a list call in list context:
  30.  
  31.             ($fore, $back) = pack_colour([0,0,0], [255, 255, 255])
  32.             # Black on white
  33.  
  34.  
  35.     unpack_colour <colour>, ...
  36.         `unpack_clour' converts 4 byte colours to arrays of RGB
  37.         values. When called in scalar context a single array
  38.         reference is returned for the first argument. When called in
  39.         list context an <array of array references> is returned.
  40.  
  41.             ($fore, $back) = unpack_colour ($fore_raw, $back_raw);
  42.             print "Red = $$fore[0]; Green = $$fore[1]; $Blue = $$fore[2]\n";
  43.  
  44.  
  45. BUGS
  46.     Not tested enough yet.
  47.  
  48. AUTHOR
  49.     Nicholas Clark <nick@unfortu.net>
  50.  
  51.