synfig-core  1.0.3
plant.h
Go to the documentation of this file.
1 /* === S Y N F I G ========================================================= */
22 /* ========================================================================= */
23 
24 /* === S T A R T =========================================================== */
25 
26 #ifndef __SYNFIG_PLANT_H
27 #define __SYNFIG_PLANT_H
28 
29 /* === H E A D E R S ======================================================= */
30 
31 #include <list>
32 #include <vector>
34 #include <synfig/segment.h>
35 #include <synfig/blinepoint.h>
36 #include <synfig/value.h>
37 #include <synfig/gradient.h>
38 #include <synfig/angle.h>
39 #include "random.h"
40 #include <synfig/rect.h>
41 
42 /* === M A C R O S ========================================================= */
43 
44 /* === T Y P E D E F S ===================================================== */
45 
46 /* === C L A S S E S & S T R U C T S ======================================= */
47 
48 using namespace synfig;
49 using namespace std;
50 using namespace etl;
51 
52 class Plant : public Layer_Composite, public Layer_NoDeform
53 {
55 private:
57  ValueBase param_bline;
59  ValueBase param_origin;
61  ValueBase param_gradient;
63  ValueBase param_split_angle;
65  ValueBase param_gravity;
67  ValueBase param_velocity;
69  ValueBase param_perp_velocity;
71  ValueBase param_size;
73  ValueBase param_size_as_alpha;
75  ValueBase param_reverse;
77  ValueBase param_step;
79  ValueBase param_random;
81  ValueBase param_splits;
83  ValueBase param_sprouts;
85  ValueBase param_random_factor;
87  ValueBase param_drag;
89  ValueBase param_use_width;
90 
91  bool bline_loop;
92 
93  struct Particle
94  {
95  Point point;
96  Color color;
97 
98  Particle(const Point &point,const Color& color):
99  point(point),color(color) { }
100  };
101 
102  mutable std::vector<Particle> particle_list;
103  mutable Rect bounding_rect;
104  Real mass;
105 
106  mutable bool needs_sync_;
107  mutable Mutex mutex;
108 
109  void branch(int n, int depth,float t, float stunt_growth, Point position,Vector velocity)const;
110  void sync()const;
111  String version;
112  void draw_particles(Surface *surface, const RendDesc &renddesc)const;
113  void draw_particles(cairo_t *cr)const;
114 
115 public:
116 
117  Plant();
118 
119  void calc_bounding_rect()const;
120 
121  virtual bool set_param(const String & param, const ValueBase &value);
122 
123  virtual ValueBase get_param(const String & param)const;
124 
125  virtual bool set_version(const String &ver);
126 
127  virtual Vocab get_param_vocab()const;
128 
129  virtual bool accelerated_render(Context context,Surface *surface,int quality, const RendDesc &renddesc, ProgressCallback *cb)const;
130  virtual bool accelerated_cairorender(Context context, cairo_t *cr, int quality, const RendDesc &renddesc, ProgressCallback *cb)const;
132  virtual Rect get_bounding_rect(Context context)const;
133 };
134 
135 /* === E N D =============================================================== */
136 
137 #endif