#ifndef RIPPLING_MATH_H_\r
#define RIPPLING_MATH_H_\r
\r
-#include <math>\r
+#include "MathTools.h"\r
+#include <cmath>\r
using namespace std;\r
\r
/*----------------------------------------------------------------------*\\r
\*-------------------------------------*/\r
\r
public:\r
-\r
- RipplingMath(unsigned int w, unsigned int h))\r
+ RipplingMath(unsigned int w, unsigned int h)\r
+ : dim2 { w / 2.0 }\r
{\r
- this->dim2 = w / 2;\r
}\r
\r
- virtual ~RipplingMath(void)\r
+ virtual ~RipplingMath()\r
{\r
//rien\r
}\r
\*-------------------------------------*/\r
\r
public:\r
-\r
void colorIJ(uchar4* ptrColor, int i, int j, float t)\r
{\r
- // TODO\r
- math::sin(9.1);\r
-asda\r
- double a { 4 / 3 };\r
+ const double dxy10 = dxy(j, i) / 10.0;\r
+ const double grayLevelFloat = 128.0 + 127.0 * cos(dxy10 - t / 7.0) / (dxy10 + 1);\r
+ const uchar grayLevel = (uchar)(long(grayLevelFloat) % 256);\r
+\r
+ ptrColor->x = grayLevel;\r
+ ptrColor->y = grayLevel;\r
+ ptrColor->z = grayLevel;\r
+\r
+ ptrColor->w = 255; // Opaque.\r
}\r
\r
private:\r
-\r
- void dxy(int i, int j, float* ptrResult) // par exmple\r
+ inline double dxy(int x, int y) // par exmple\r
{\r
- //TODO\r
+ return sqrt(pow(x - this->dim2, 2.0) + pow(y - this->dim2, 2.0));\r
}\r
\r
private:\r
\*-------------------------------------*/\r
\r
private:\r
-\r
- // Tools\r
- double dim2; //=dim/2\r
-\r
+ const double dim2; // = dim / 2.\r
};\r
\r
#endif\r