55 lines
1.2 KiB
C++
55 lines
1.2 KiB
C++
#ifndef ELEMENT_H
|
|
#define ELEMENT_H
|
|
|
|
#include "canvas.h"
|
|
|
|
constexpr unsigned NumWeight = 10;
|
|
static constexpr double M_PI = 3.1415926;
|
|
|
|
class BackGround : public Canvas {
|
|
public:
|
|
BackGround (const int w, const int h) : Canvas (w, h) {};
|
|
virtual ~BackGround (){};
|
|
void drawings ();
|
|
};
|
|
class ForeGround : public Canvas {
|
|
unsigned index, speed;
|
|
double weights [NumWeight];
|
|
public:
|
|
ForeGround (const int w, const int h) : Canvas (w, h) {
|
|
normalize();
|
|
};
|
|
virtual ~ForeGround (){};
|
|
void drawings ();
|
|
void setWeight (const int n, const int w) {
|
|
weights [n] = (double) w * 0.01;
|
|
}
|
|
void changeSpeed (int s) { speed = s; };
|
|
void step ();
|
|
void reset () {
|
|
index = 0;
|
|
}
|
|
protected:
|
|
double probality (const double x) const;
|
|
void phase ();
|
|
void normalize ();
|
|
};
|
|
struct CommonPlots {
|
|
int maxx, maxy;
|
|
bool StartStop;
|
|
BackGround * bg;
|
|
ForeGround * fg;
|
|
CommonPlots (const int w, const int h) : maxx (w), maxy(h) {
|
|
bg = new BackGround (w,h);
|
|
fg = new ForeGround (w,h);
|
|
bg->drawings();
|
|
fg->drawings();
|
|
StartStop = false;
|
|
}
|
|
~CommonPlots () {
|
|
delete bg;
|
|
delete fg;
|
|
}
|
|
};
|
|
|
|
#endif // ELEMENT_H
|