00001
00022
00023
00024
00025
00026 #ifndef __SYNFIG_LAYER_CIRCLE_H__
00027 #define __SYNFIG_LAYER_CIRCLE_H__
00028
00029
00030
00031 #include <synfig/layer_composite.h>
00032 #include <synfig/color.h>
00033 #include <synfig/vector.h>
00034
00035 using namespace synfig;
00036 using namespace std;
00037 using namespace etl;
00038
00039
00040
00041
00042
00043
00044
00045 class Circle : public synfig::Layer_Composite, public synfig::Layer_NoDeform
00046 {
00047 SYNFIG_LAYER_MODULE_EXT
00048 private:
00049 synfig::Color color;
00050 synfig::Point origin;
00051 synfig::Real radius;
00052 synfig::Real feather;
00053 bool invert;
00054 int falloff;
00055
00056
00057 struct CircleDataCache
00058 {
00059 Real inner_radius;
00060 Real outer_radius;
00061
00062 Real inner_radius_sqd;
00063 Real outer_radius_sqd;
00064
00065 Real diff_sqd;
00066 Real double_feather;
00067 };
00068
00069 typedef Real FALLOFF_FUNC(const CircleDataCache &c, const Real &mag_sqd);
00070
00071 FALLOFF_FUNC *falloff_func;
00072 CircleDataCache cache;
00073
00074 void constructcache();
00075
00076 static Real SqdFalloff(const CircleDataCache &c, const Real &mag_sqd);
00077 static Real InvSqdFalloff(const CircleDataCache &c, const Real &mag_sqd);
00078 static Real SqrtFalloff(const CircleDataCache &c, const Real &mag_sqd);
00079 static Real InvSqrtFalloff(const CircleDataCache &c, const Real &mag_sqd);
00080 static Real LinearFalloff(const CircleDataCache &c, const Real &mag_sqd);
00081 static Real InvLinearFalloff(const CircleDataCache &c, const Real &mag_sqd);
00082 static Real SigmondFalloff(const CircleDataCache &c, const Real &mag_sqd);
00083 static Real InvSigmondFalloff(const CircleDataCache &c, const Real &mag_sqd);
00084 static Real CosineFalloff(const CircleDataCache &c, const Real &mag_sqd);
00085 static Real InvCosineFalloff(const CircleDataCache &c, const Real &mag_sqd);
00086
00087 FALLOFF_FUNC *GetFalloffFunc()const;
00088 bool ImportParameters(const String ¶m, const ValueBase &value);
00089
00090 public:
00091 enum Falloff
00092 {
00093 FALLOFF_SQUARED =0,
00094 FALLOFF_INTERPOLATION_LINEAR =1,
00095 FALLOFF_SMOOTH =2,
00096 FALLOFF_COSINE =2,
00097 FALLOFF_SIGMOND =3,
00098 FALLOFF_SQRT =4
00099 };
00100
00101 Circle();
00102
00103 virtual bool set_param(const String ¶m, const ValueBase &value);
00104
00105 virtual ValueBase get_param(const String ¶m)const;
00106
00107 virtual Color get_color(Context context, const Point &pos)const;
00108
00109 virtual bool accelerated_render(Context context,Surface *surface,int quality, const RendDesc &renddesc, ProgressCallback *cb)const;
00110
00111 virtual synfig::Rect get_full_bounding_rect(synfig::Context context)const;
00112 virtual synfig::Rect get_bounding_rect()const;
00113
00114 synfig::Layer::Handle hit_check(synfig::Context context, const synfig::Point &point)const;
00115
00116 virtual Vocab get_param_vocab()const;
00117 };
00118
00119
00120
00121
00122
00123
00124 #endif