radialgradient.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
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