Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

Colour.h

Go to the documentation of this file.
00001 /*
00002     File:           Colour.h
00003     
00004     Function:       Definitions and classes for handling Colour
00005 
00006     Author(s):      Andrew Willmott
00007 
00008     Copyright:      (c) 1995-2000, Andrew Willmott
00009  */
00010  
00011 #ifndef __Colour__
00012 #define __Colour__
00013 
00014 #include "gcl/GCLConfig.h"
00015 
00016 #ifndef GCL_CLR_DOUBLE
00017 #include "vl/VLf.h"
00018 typedef Vec3f Colour;
00019 typedef Vec4f Colour4;
00020 typedef Mat3f ClrMat;
00021 typedef Mat4f ClrTrans;
00022 typedef Float ClrReal;
00023 #else
00024 #include "vl/VLd.h"
00025 typedef Vec3d Colour;
00026 typedef Vec4d Colour4;
00027 typedef Mat3d ClrMat;
00028 typedef Mat4d ClrTrans;
00029 typedef Double ClrReal;
00030 #endif
00031 
00032 #include "cl/Array.h"
00033 #include "cl/NArray.h"
00034 
00044 inline Colour   RGBCol(ClrReal r, ClrReal g, ClrReal b)
00045                 { return(Colour(r, g, b)); }
00046 Colour          HSVCol(ClrReal hue, ClrReal saturation, ClrReal value);
00047 
00048 typedef Colour Reflectance;
00049 typedef NArray<Colour> ColourList;
00050 typedef NArray<Colour4> Colour4List;
00051 typedef ColourList ReflList;
00052 
00053 Colour &ClipColour(Colour &c);
00055 Colour &ClipColourZero(Colour &c);
00057 inline Colour ClrMix(const Colour &c1, const Colour &c2, ClrReal mix)
00058 {
00059     return(c1 * (1.0 - mix) + c2 * mix);
00060 }
00062 
00063 
00064 // --- Useful conversion factors/functions ------------------------------------
00065 
00066 const Reflectance cRGBToNTSCLum(0.299, 0.587, 0.114);   
00070 const Reflectance cRGBToLum(0.3086, 0.6094, 0.0820);    
00072 
00073 const ClrMat cNTSCToCIE(
00074                 0.67, 0.21, 0.14,           // From Sillion & Puesch
00075                 0.33, 0.71, 0.08,           // "Radiosity", pp 211.
00076                 0.00, 0.08, 0.78); 
00077 
00078 const ClrMat cCIEToNTSC(
00079                 1.730, -0.482, -0.261,
00080                -0.814,  1.652, -0.023,
00081                 0.083, -0.169,  1.284); 
00082 
00083 const ClrMat cRGBToYIQ(
00084                 0.299,  0.587,  0.114,
00085                 0.596, -0.275, -0.321,
00086                 0.212, -0.523,  0.311);
00087 
00088 const ClrMat cYIQToRGB(
00089                 1.0,   0.956,   0.621,
00090                 1.0,  -0.272,  -0.647,
00091                 1.0,  -1.105,   1.702);
00092 
00093 Colour YUVToRGB(const Colour &yuv);
00094 Colour RGBToYUV(const Colour &rgb);
00096 
00097 
00098 // --- Useful colour constants ------------------------------------------------
00099 
00100 // RGB Constants
00101 
00102 const Colour cBlack(0, 0, 0);
00103 const Colour cWhite(1, 1, 1);
00104 
00105 const Colour cGrey(cWhite * 0.5);
00106 const Colour cGrey05(cWhite * 0.05);
00107 const Colour cGrey10(cWhite * 0.1);
00108 const Colour cGrey25(cWhite * 0.25);
00109 const Colour cGrey50(cWhite * 0.5);
00110 const Colour cGrey75(cWhite * 0.75);
00111 const Colour cGrey90(cWhite * 0.90);
00112 const Colour cGrey95(cWhite * 0.95);
00113 
00114 const Colour cRed(1, 0, 0);
00115 const Colour cOrange(1, 0.5, 0);
00116 const Colour cYellow(1, 1, 0);
00117 const Colour cGreen(0, 1, 0);
00118 const Colour cCyan(0, 1, 1);
00119 const Colour cBlue(0, 0, 1);
00120 const Colour cPurple(1, 0, 1);
00121 
00122 // HSV constants
00123 
00124 const Int hsvRed    =    0;
00125 const Int hsvOrange =   30;
00126 const Int hsvYellow =   60;
00127 const Int hsvGreen  =  120;
00128 const Int hsvCyan   =  180;
00129 const Int hsvBlue   =  240;
00130 const Int hsvPurple =  300;
00131 
00132 
00133 // --- Colour transformations -------------------------------------------------
00134 
00136 
00137 ClrTrans    RGBScale(ClrReal rscale, ClrReal gscale, ClrReal bscale);
00138 ClrTrans    RGBOffset(const Colour &c);
00139 ClrTrans    RGBReplace(const Colour &c);
00140 ClrTrans    RGBToLum();
00141 
00142 ClrTrans    RGBSaturate(ClrReal sat);
00147 ClrTrans    RGBPixelMix(ClrReal mix, const Colour &c);
00154 ClrTrans    RGBHueRotate(ClrReal degrees);
00156 #endif

Generated at Sat Aug 5 00:16:58 2000 for Graphics Class Library by doxygen 1.1.0 written by Dimitri van Heesch, © 1997-2000