papyrus logo

radialgradient.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2009 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 PAPYRUSRADIALGRADIENT_H
00021 #define PAPYRUSRADIALGRADIENT_H
00022 
00023 #include <papyrus/lineargradient.h>
00024 #include <papyrus/primitives.h>
00025 
00026 namespace Papyrus
00027 {
00028 
00037   class RadialGradient : public Gradient
00038   {
00039     public:
00040       struct Circle: public LinearGradient::Point {
00041         Circle( double x=0.0, double y=0.0, double cr=0.0, Quantity q=ABSOLUTE ): LinearGradient::Point(x,y,q), r(cr), quantity_r(q) { }
00042         Circle( double x, double y, double cr, Quantity qx, Quantity qy, Quantity qr ): LinearGradient::Point(x,y,qx,qy), r(cr), quantity_r(qr) { }
00043         Circle( const Papyrus::Point& p, double cr, Quantity q=ABSOLUTE ): LinearGradient::Point(p,q), r(cr), quantity_r(q) { }
00044         Circle( const Papyrus::Point& p, double cr, Quantity qx, Quantity qy, Quantity qr ): LinearGradient::Point(p,qx,qy), r(cr), quantity_r(qr) { }
00045         Circle( const Circle& p ): LinearGradient::Point(p), r(p.r), quantity_r(p.quantity_r) { }
00046 
00047         bool has_percent()
00048         {
00049           return quantity_x == PERCENT or
00050               quantity_y == PERCENT or
00051               quantity_r == PERCENT;
00052         }
00053 
00054         virtual operator bool() { return ( not isnan(x) and not isnan(y) and not isnan(r) ); }
00055 
00056         double r;
00057         Quantity quantity_r;
00058       };
00059 
00060     protected:
00061       
00062       RadialGradient(const Circle& outer, const Circle& inner);
00063 
00064     public:
00065       PAPYRUS_RENDERABLE(RadialGradient);
00066 
00067       static pointer create( double ox, double oy, double orad, Quantity q=ABSOLUTE );
00068       
00069       static pointer create( const Circle& outer );
00070       
00071       static pointer create( const Circle& outer, const Circle& inner );
00072       
00073       virtual ~RadialGradient();
00074 
00075       const Circle& outer_circle() const;
00076 
00077       void set_outer_circle( const Circle& outer );
00078       
00079       const Circle& inner_circle() const;
00080 
00081       void set_inner_circle( const Circle& inner );
00082       
00083       void set_circles( const Circle& outer, const Circle& inner );
00084       
00085       virtual void render ( Context& cairo ) const;
00086 
00087     protected:
00088       Circle m_outer_circle, m_inner_circle;
00089   };
00090 
00091 }
00092 
00093 #endif

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