75 const QRect& applyRect,
85 QPoint srcTopLeft = applyRect.topLeft();
89 quint32 DropSize = config->getInt(
"dropSize", 80);
90 quint32 number = config->getInt(
"number", 80);
91 quint32 fishEyes = config->getInt(
"fishEyes", 30);
92 QRandomGenerator rng(config->getInt(
"seed"));
94 if (fishEyes <= 0) fishEyes = 1;
96 if (fishEyes > 100) fishEyes = 100;
98 int Width = applyRect.width();
99 int Height = applyRect.height();
103 int i, j, k, l, m, n;
115 double NewfishEyes = (double)fishEyes * 0.01;
119 bool FindAnother =
false;
125 for (i = 0 ; i < Width; ++i) {
126 for (j = 0 ; j < Height; ++j) {
127 BoolMatrix[i][j] =
false;
131 progressUpdater->
setRange(0, number);
134 for (
uint NumBlurs = 0; NumBlurs <= number; ++NumBlurs) {
135 NewSize = 5 +
static_cast<int>(rng.bounded(1.0) * (DropSize - 5));
136 halfSize = NewSize / 2;
138 s = Radius / log(NewfishEyes * Radius + 1);
144 y =
static_cast<int>(rng.bounded(
static_cast<double>(Width - 1)));
145 x =
static_cast<int>(rng.bounded(
static_cast<double>(Height - 1)));
147 if (BoolMatrix[y][x])
150 for (i = x - halfSize ; i <= x + halfSize; i++)
151 for (j = y - halfSize ; j <= y + halfSize; j++)
152 if ((i >= 0) && (i < Height) && (j >= 0) && (j < Width))
153 if (BoolMatrix[j][i])
157 }
while (FindAnother && Counter < 10000);
159 if (Counter >= 10000) {
164 for (i = -1 * halfSize ; i < NewSize - halfSize; i++) {
165 for (j = -1 * halfSize ; j < NewSize - halfSize; j++) {
166 r = sqrt((
double)i * i + j * j);
167 a = atan2(
static_cast<double>(i),
static_cast<double>(j));
171 r = (exp(r / s) - 1) / NewfishEyes;
173 k = x + (int)(r * sin(a));
174 l = y + (int)(r * cos(a));
179 if ((k >= 0) && (k < Height) && (l >= 0) && (l < Width)) {
180 if ((m >= 0) && (m < Height) && (n >= 0) && (n < Width)) {
183 if (OldRadius >= 0.9 * Radius) {
184 if ((a <= 0) && (a > -2.25))
186 else if ((a <= -2.25) && (a > -2.5))
188 else if ((a <= 0.25) && (a > 0))
192 else if (OldRadius >= 0.8 * Radius) {
193 if ((a <= -0.75) && (a > -1.50))
195 else if ((a <= 0.10) && (a > -0.75))
197 else if ((a <= -1.50) && (a > -2.35))
201 else if (OldRadius >= 0.7 * Radius) {
202 if ((a <= -0.10) && (a > -2.0))
204 else if ((a <= 2.50) && (a > 1.90))
208 else if (OldRadius >= 0.6 * Radius) {
209 if ((a <= -0.50) && (a > -1.75))
211 else if ((a <= 0) && (a > -0.25))
213 else if ((a <= -2.0) && (a > -2.25))
217 else if (OldRadius >= 0.5 * Radius) {
218 if ((a <= -0.25) && (a > -0.50))
220 else if ((a <= -1.75) && (a > -2.0))
224 else if (OldRadius >= 0.4 * Radius) {
225 if ((a <= -0.5) && (a > -1.75))
229 else if (OldRadius >= 0.3 * Radius) {
230 if ((a <= 0) && (a > -2.25))
234 else if (OldRadius >= 0.2 * Radius) {
235 if ((a <= -0.5) && (a > -1.75))
239 BoolMatrix[n][m] =
true;
241 QColor originalColor;
243 dstAccessor->
moveTo(srcTopLeft.x() + l, srcTopLeft.y() + k);
251 newColor.setRgb(newRed, newGreen, newBlue);
253 dstAccessor->
moveTo(srcTopLeft.x() + n, srcTopLeft.y() + m);
261 BlurRadius = NewSize / 25 + 1;
263 for (i = -1 * halfSize - BlurRadius ; i < NewSize - halfSize + BlurRadius; i++) {
264 for (j = -1 * halfSize - BlurRadius; j < NewSize - halfSize + BlurRadius; ++j) {
265 r = sqrt((
double)i * i + j * j);
267 if (r <= Radius * 1.1) {
271 for (k = -1 * BlurRadius; k < BlurRadius + 1; k++)
272 for (l = -1 * BlurRadius; l < BlurRadius + 1; l++) {
276 if ((m >= 0) && (m < Height) && (n >= 0) && (n < Width)) {
278 dstAccessor->
moveTo(srcTopLeft.x() + n, srcTopLeft.y() + m);
291 if ((m >= 0) && (m < Height) && (n >= 0) && (n < Width)) {
294 if (BlurPixels == 0) {
301 color.setRgb((
int)(
R / BlurPixels), (
int)(
G / BlurPixels), (
int)(
B / BlurPixels));
302 dstAccessor->
moveTo(srcTopLeft.x() + n, srcTopLeft.y() + m);
309 progressUpdater->
setValue(NumBlurs);