papyrus logo

rgba.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2006 by Rick L. Vinyard, Jr.                            *
00003  *   rvinyard@cs.nmsu.edu                                                  *
00004  *                                                                         *
00005  *   This file is part of the papyrus library.                             *
00006  *                                                                         *
00007  *   papyrus is free software; you can redistribute it and/or modify       *
00008  *   it under the terms of the GNU Lesser General Public License           *
00009  *   version 3.0 as published by the Free Software Foundation.             *
00010  *                                                                         *
00011  *   papyrus is distributed in the hope that it will be useful,            *
00012  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00013  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00014  *   GNU Lesser General Public License version 3.0 for more details.       *
00015  *                                                                         *
00016  *   You should have received a copy of the GNU Lesser General Public      *
00017  *   License along with the papyrus library. If not, see                   *
00018  *   <http://www.gnu.org/licenses/>.                                       *
00019  ***************************************************************************/
00020 #ifndef PAPYRUSRGBA_H
00021 #define PAPYRUSRGBA_H
00022 
00023 #include <regex.h>
00024 #include <string>
00025 
00026 #include <cairomm/pattern.h>
00027 #include <papyrus/fill.h>
00028 #include <papyrus/stroke.h>
00029 #include <papyrus/paint.h>
00030 
00031 namespace Papyrus {
00032 
00033 typedef enum COLOR_INDEXES {
00034   RED=0x00,
00035   GREEN=0x01,
00036   BLUE=0x02,
00037   HUE=0x00,
00038   SATURATION=0x01,
00039   BRIGHTNESS=0x02,
00040   LIGHTNESS=0x02,
00041   ALPHA=0x03
00042 } COLOR_INDEXES;
00043 
00047 struct RGBA {
00048 
00049   RGBA(double r=0.0, double g=0.0, double b=0.0, double a=1.0);
00050 
00051   RGBA(const Glib::ustring& name, double a=1.0);
00052 
00053   double red, green, blue, alpha;
00054 
00055   double operator[](unsigned index);
00056 
00057   operator Cairo::RefPtr<Cairo::Pattern>() const;
00058 
00059   operator Fill::pointer() const;
00060 
00061   operator Stroke::pointer() const;
00062 
00063   operator Paint::pointer() const;
00064 
00065   private:
00066   // TODO make this threadsafe
00067   static regex_t regular_expression[4];
00068   static bool regex_initialized;
00069 
00070   static void initialize_regular_expressions();
00071 
00072 };
00073 
00074 }
00075 #endif

Generated on Fri Apr 16 12:40:11 2010 for papyrus by doxygen 1.6.1