00001 #include "distort.h"
00002
00004
00006
00007 {
00008 glutSetWindowTitle("Paint Application | Mosaic");
00009
00010 startup(_img, _temp, _temp2, _hud, _menu, _bArea, _lowArea, _highArea);
00011
00012 value1 = 10;
00013 value2 = 1;
00014 if ((highArea.x - lowArea.x + 1) > (highArea.y - lowArea.y + 1))
00015 limitValue1.set(1, int((highArea.x - lowArea.x + 1)/5));
00016 else
00017 limitValue1.set(1, int((highArea.y - lowArea.y + 1)/5));
00018 limitValue2.set(0, int(value1 - 1));
00019 imageRgbaCopy(img, temp);
00020
00021 bColorMenu = true;
00022 myColor = (Rgba){0, 0, 0, 255};
00023
00024 LBpressed = true;
00025 this->LBAction();
00026 LBpressed = false;
00027 }
00028
00029 void mosaic::colorChangeAction()
00030 {
00031 if (!LBpressed)
00032 {
00033 LBpressed = true;
00034 this->LBAction();
00035 LBpressed = false;
00036 }
00037 else
00038 this->LBAction();
00039 }
00040
00041 void mosaic::LBAction()
00042 {
00043 if (LBpressed)
00044 {
00045 limitValue2.set(0, int(value1 - 1));
00046 value2 = limitValue2.intForceLimit(value2);
00047
00048 int w = highArea.x - lowArea.x + 1;
00049 int h = highArea.y - lowArea.y + 1;
00050
00051 for (int by = 0; by < int(1.0 * h / value1 + 1); by++)
00052 {
00053 for (int bx = 0; bx < int(1.0 * w / value1 + 1); bx++)
00054 {
00055 int R = 0, G = 0, B = 0, count = 0;
00056 int newX, newY;
00057
00058 for (int y = 0; y < value1; y++)
00059 {
00060 newY = int(lowArea.y + by*value1 + y);
00061 if ((newY >= lowArea.y) && (newY <= highArea.y))
00062 {
00063 for (int x = 0; x < value1; x++)
00064 {
00065 newX = int(lowArea.x + bx*value1 + x);
00066
00067 if ((newX >= lowArea.x) && (newX <= highArea.x))
00068 {
00069 count++;
00070 R += temp->data[newX + img->width * newY].r;
00071 G += temp->data[newX + img->width * newY].g;
00072 B += temp->data[newX + img->width * newY].b;
00073 }
00074 }
00075 }
00076 }
00077
00078 if (count != 0)
00079 {
00080 R = limitRGBA.intForceLimit(R / count);
00081 G = limitRGBA.intForceLimit(G / count);
00082 B = limitRGBA.intForceLimit(B / count);
00083 }
00084
00085 for (int y = 0; y < value1; y++)
00086 {
00087 newY = int(lowArea.y + by*value1 + y);
00088 if ((newY >= lowArea.y) && (newY <= highArea.y))
00089 {
00090 for (int x = 0; x < value1; x++)
00091 {
00092 newX = int(lowArea.x + bx*value1 + x);
00093
00094 if ((newX >= lowArea.x) && (newX <= highArea.x))
00095 {
00096 if (x < int(value2 / 2.0) || x >= int(value1 - (value2 / 2.0)) || y < int(value2 / 2.0) || y >= int(value1 - (value2 / 2.0)))
00097 img->data[newX + img->width * newY] = myColor;
00098 else
00099 img->data[newX + img->width * newY] = (Rgba){R, G, B, 255};
00100 }
00101 else
00102 break;
00103 }
00104 }
00105 else
00106 break;
00107 }
00108 }
00109 }
00110 }
00111 }
00112
00114
00116
00117 {
00118 glutSetWindowTitle("Paint Application | Box");
00119
00120 startup(_img, _temp, _temp2, _hud, _menu, _bArea, _lowArea, _highArea);
00121
00122 value1 = 10;
00123 if ((highArea.x - lowArea.x + 1) > (highArea.y - lowArea.y + 1))
00124 limitValue1.set(1, int((highArea.x - lowArea.x + 1)/5));
00125 else
00126 limitValue1.set(1, int((highArea.y - lowArea.y + 1)/5));
00127 value2 = 1;
00128 limitValue2.set(0, int(value1 / 2.0 - 1));
00129 imageRgbaCopy(img, temp);
00130
00131 numModes = 8;
00132 mode = 6;
00133
00134 LBpressed = true;
00135 this->LBAction();
00136 LBpressed = false;
00137 }
00138
00139 void box::LBAction()
00140 {
00141 if (LBpressed)
00142 {
00143 limitValue2.set(0, int(value1 / 2.0 - 1));
00144 value2 = limitValue2.intForceLimit(value2);
00145
00146 int w = highArea.x - lowArea.x + 1;
00147 int h = highArea.y - lowArea.y + 1;
00148
00149 for (int by = 0; by < int(1.0 * h / value1 + 1); by++)
00150 {
00151 for (int bx = 0; bx < int(1.0 * w / value1 + 1); bx++)
00152 {
00153 int R = 0, G = 0, B = 0, count = 0;
00154 int newX, newY;
00155
00156 for (int y = 0; y < value1; y++)
00157 {
00158 newY = int(lowArea.y + by*value1 + y);
00159 if ((newY >= lowArea.y) && (newY <= highArea.y))
00160 {
00161 for (int x = 0; x < value1; x++)
00162 {
00163 newX = int(lowArea.x + bx*value1 + x);
00164
00165 if ((newX >= lowArea.x) && (newX <= highArea.x))
00166 {
00167 int location = newX + img->width * newY;
00168
00169 count++;
00170 R += temp->data[location].r;
00171 G += temp->data[location].g;
00172 B += temp->data[location].b;
00173 }
00174 }
00175 }
00176 }
00177
00178 if (count != 0)
00179 {
00180 R = limitRGBA.intForceLimit(R / count);
00181 G = limitRGBA.intForceLimit(G / count);
00182 B = limitRGBA.intForceLimit(B / count);
00183 }
00184
00185 for (int y = 0; y < value1; y++)
00186 {
00187 newY = int(lowArea.y + by*value1 + y);
00188 if ((newY >= lowArea.y) && (newY <= highArea.y))
00189 {
00190 for (int x = 0; x < value1; x++)
00191 {
00192 newX = int(lowArea.x + bx*value1 + x);
00193
00194 if ((newX >= lowArea.x) && (newX <= highArea.x))
00195 {
00196 int location = newX + img->width * newY;
00197
00198 img->data[location] = (Rgba){R, G, B};
00199 }
00200 }
00201 }
00202 }
00203 }
00204 }
00205 for (int by = 0; by < int(1.0 * h / value1 + 1); by++)
00206 {
00207 for (int bx = 0; bx < int(1.0 * w / value1 + 1); bx++)
00208 {
00209 int dU = 0, dD = 0, dL = 0, dR = 0;
00210 int vSelf, vOther;
00211 int newX, newY;
00212 Rgba colorSelf, colorOther;
00213
00214 if (bx > 0 && by > 0 && bx < int(1.0 * w / value1) && by < int(1.0 * h / value1))
00215 {
00216
00217 colorSelf = img->data[int(lowArea.x + (bx - 0)*value1 + (value1 / 2.0)) + img->width * int(lowArea.y + (by - 0)*value1 + (value1 / 2.0))];
00218 colorOther = img->data[int(lowArea.x + (bx - 0)*value1 + (value1 / 2.0)) + img->width * int(lowArea.y + (by - 1)*value1 + (value1 / 2.0))];
00219 vSelf = colorSelf.r;
00220 if (colorSelf.g > vSelf)
00221 vSelf = colorSelf.g;
00222 if (colorSelf.b > vSelf)
00223 vSelf = colorSelf.b;
00224
00225 vOther = colorOther.r;
00226 if (colorOther.g > vOther)
00227 vOther = colorOther.g;
00228 if (colorOther.b > vOther)
00229 vOther = colorOther.b;
00230
00231 dU = vSelf - vOther;
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251 colorSelf = img->data[int(lowArea.x + (bx - 0)*value1 + (value1 / 2.0)) + img->width * int(lowArea.y + (by - 0)*value1 + (value1 / 2.0))];
00252 colorOther = img->data[int(lowArea.x + (bx - 1)*value1 + (value1 / 2.0)) + img->width * int(lowArea.y + (by - 0)*value1 + (value1 / 2.0))];
00253 vSelf = colorSelf.r;
00254 if (colorSelf.g > vSelf)
00255 vSelf = colorSelf.g;
00256 if (colorSelf.b > vSelf)
00257 vSelf = colorSelf.b;
00258
00259 vOther = colorOther.r;
00260 if (colorOther.g > vOther)
00261 vOther = colorOther.g;
00262 if (colorOther.b > vOther)
00263 vOther = colorOther.b;
00264
00265 dL = vSelf - vOther;
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283 }
00284
00285 for (int y = 0; y < value1; y++)
00286 {
00287 newY = int(lowArea.y + by*value1 + y);
00288 if ((newY >= lowArea.y) && (newY <= highArea.y))
00289 {
00290 for (int x = 0; x < value1; x++)
00291 {
00292 newX = int(lowArea.x + bx*value1 + x);
00293
00294 if ((newX >= lowArea.x) && (newX <= highArea.x))
00295 {
00296 int newMode;
00297 if (mode > 4)
00298 newMode = (mode - 4) * 2 - 1;
00299 else
00300 newMode = (mode - 5) * 2 + 1;
00301
00302 int location = newX + img->width * newY;
00303 if (y < value2 && y <= x && y < (value1 - x))
00304 {
00305 img->data[location].r = limitRGBA.intForceLimit(img->data[location].r + 50 + dU * newMode);
00306 img->data[location].g = limitRGBA.intForceLimit(img->data[location].g + 50 + dU * newMode);
00307 img->data[location].b = limitRGBA.intForceLimit(img->data[location].b + 50 + dU * newMode);
00308 }
00309 else if (y >= (value1 - value2) && y > x && y >= (value1 - x))
00310 {
00311 img->data[location].r = limitRGBA.intForceLimit(img->data[location].r - 50 + dD * 0);
00312 img->data[location].g = limitRGBA.intForceLimit(img->data[location].g - 50 + dD * 0);
00313 img->data[location].b = limitRGBA.intForceLimit(img->data[location].b - 50 + dD * 0);
00314 }
00315 else if (x < value2)
00316 {
00317 img->data[location].r = limitRGBA.intForceLimit(img->data[location].r + 20 + dL * newMode);
00318 img->data[location].g = limitRGBA.intForceLimit(img->data[location].g + 20 + dL * newMode);
00319 img->data[location].b = limitRGBA.intForceLimit(img->data[location].b + 20 + dL * newMode);
00320 }
00321 else if (x >= (value1 - value2))
00322 {
00323 img->data[location].r = limitRGBA.intForceLimit(img->data[location].r - 20 + dR * 0);
00324 img->data[location].g = limitRGBA.intForceLimit(img->data[location].g - 20 + dR * 0);
00325 img->data[location].b = limitRGBA.intForceLimit(img->data[location].b - 20 + dR * 0);
00326 }
00327 }
00328 }
00329 }
00330 }
00331 }
00332 }
00333 }
00334 }
00335
00336 void box::changeMode(char _mode)
00337 {
00338 mode = _mode;
00339 if (!LBpressed)
00340 {
00341 LBpressed = true;
00342 this->LBAction();
00343 LBpressed = false;
00344 }
00345 else
00346 this->LBAction();
00347 }
00348
00350
00352
00353 {
00354 glutSetWindowTitle("Paint Application | Comb");
00355
00356 startup(_img, _temp, _temp2, _hud, _menu, _bArea, _lowArea, _highArea);
00357
00358 value1 = 10;
00359 if ((highArea.x - lowArea.x + 1) > (highArea.y - lowArea.y + 1))
00360 limitValue1.set(2, int((highArea.x - lowArea.x + 1)/5));
00361 else
00362 limitValue1.set(2, int((highArea.y - lowArea.y + 1)/5));
00363 imageRgbaCopy(img, temp);
00364
00365 LBpressed = true;
00366 this->LBAction();
00367 LBpressed = false;
00368 }
00369
00370 void comb::LBAction()
00371 {
00372 if (LBpressed)
00373 {
00374 int w = highArea.x - lowArea.x + 1;
00375 int h = highArea.y - lowArea.y + 1;
00376 int value1y = int(sqrt(3) / 2.0 * value1);
00377
00378 for (int by = 0; by < int(1.0 * h / value1y + 2); by++)
00379 {
00380 for (int bx = 0; bx < int(1.0 * w / value1 + 2); bx++)
00381 {
00382 int R1 = 0, G1 = 0, B1 = 0, count1 = 0;
00383 int R2 = 0, G2 = 0, B2 = 0, count2 = 0;
00384 int newX, newY;
00385
00386 for (int y = 0; y < value1y; y++)
00387 {
00388 newY = int(lowArea.y + by*value1y + y);
00389 if ((newY >= lowArea.y) && (newY <= highArea.y))
00390 {
00391 for (int x = int(0 - ((by % 2) * (value1 / 2.0)) + (1.0 * abs(y) / value1y * value1) / 2.0); x < (value1 - ((by % 2) * (value1 / 2.0)) - (1.0 * abs(y) / value1y * value1) / 2.0); x++)
00392 {
00393 newX = int(lowArea.x + bx*value1 + x);
00394
00395 if ((newX >= lowArea.x) && (newX <= highArea.x))
00396 {
00397 count1++;
00398 R1 += temp->data[newX + img->width * newY].r;
00399 G1 += temp->data[newX + img->width * newY].g;
00400 B1 += temp->data[newX + img->width * newY].b;
00401 }
00402 }
00403 }
00404 }
00405 for (int y = 0; y > (-value1y); y--)
00406 {
00407 newY = int(lowArea.y + by*value1y + y);
00408 if ((newY >= lowArea.y) && (newY <= highArea.y))
00409 {
00410 for (int x = int(0 - ((by % 2) * (value1 / 2.0)) + (1.0 * abs(y) / value1y * value1) / 2.0); x < (value1 - ((by % 2) * (value1 / 2.0)) - (1.0 * abs(y) / value1y * value1) / 2.0); x++)
00411 {
00412 newX = int(lowArea.x + bx*value1 + x);
00413
00414 if ((newX >= lowArea.x) && (newX <= highArea.x))
00415 {
00416 count2++;
00417 R2 += temp->data[newX + img->width * newY].r;
00418 G2 += temp->data[newX + img->width * newY].g;
00419 B2 += temp->data[newX + img->width * newY].b;
00420 }
00421 }
00422 }
00423 }
00424
00425 if (count1 != 0)
00426 {
00427 R1 = limitRGBA.intForceLimit(R1 / count1);
00428 G1 = limitRGBA.intForceLimit(G1 / count1);
00429 B1 = limitRGBA.intForceLimit(B1 / count1);
00430 }
00431 if (count2 != 0)
00432 {
00433 R2 = limitRGBA.intForceLimit(R2 / count2);
00434 G2 = limitRGBA.intForceLimit(G2 / count2);
00435 B2 = limitRGBA.intForceLimit(B2 / count2);
00436 }
00437
00438 for (int y = 0; y < value1y; y++)
00439 {
00440 newY = int(lowArea.y + by*value1y + y);
00441 if ((newY >= lowArea.y) && (newY <= highArea.y))
00442 {
00443 for (int x = int(0 - ((by % 2) * (1.0 * value1 / 2.0)) + (1.0 * abs(y) / value1y * value1) / 2.0); x < (value1 - ((by % 2) * (1.0 * value1 / 2.0)) - (1.0 * abs(y) / value1y * value1) / 2.0); x++)
00444 {
00445 newX = int(lowArea.x + bx*value1 + x);
00446
00447 if ((newX >= lowArea.x) && (newX <= highArea.x))
00448 img->data[newX + img->width * newY] = (Rgba) {R1, G1, B1, 255};
00449 }
00450 }
00451 }
00452 for (int y = 0; y > (-value1y); y--)
00453 {
00454 newY = int(lowArea.y + by*value1y + y);
00455 if ((newY >= lowArea.y) && (newY <= highArea.y))
00456 {
00457 for (int x = int(0 - ((by % 2) * (1.0 * value1 / 2.0)) + (1.0 * abs(y) / value1y * value1) / 2.0); x < (value1 - ((by % 2) * (1.0 * value1 / 2.0)) - (1.0 * abs(y) / value1y * value1) / 2.0); x++)
00458 {
00459 newX = int(lowArea.x + bx*value1 + x);
00460
00461 if ((newX >= lowArea.x) && (newX <= highArea.x))
00462 img->data[newX + img->width * newY] = (Rgba) {R2, G2, B2, 255};
00463 }
00464 }
00465 }
00466 }
00467 }
00468 }
00469 }
00470
00472
00474
00475 {
00476 glutSetWindowTitle("Paint Application | Dots");
00477
00478 startup(_img, _temp, _temp2, _hud, _menu, _bArea, _lowArea, _highArea);
00479
00480 value1 = 30;
00481 if ((highArea.x - lowArea.x + 1) > (highArea.y - lowArea.y + 1))
00482 limitValue1.set(2, (highArea.x - lowArea.x + 1));
00483 else
00484 limitValue1.set(2, (highArea.y - lowArea.y + 1));
00485
00486 value2 = 10;
00487 limitValue2.set(0, int(value1 / 2.0));
00488
00489 bColorMenu = true;
00490 myColor = (Rgba){0, 0, 0, 255};
00491
00492 imageRgbaCopy(img, temp);
00493
00494 numModes = 2;
00495 this->changeMode(1);
00496 }
00497
00498 void dots::colorChangeAction()
00499 {
00500 if (!LBpressed)
00501 {
00502 LBpressed = true;
00503 this->LBAction();
00504 LBpressed = false;
00505 }
00506 else
00507 this->LBAction();
00508 }
00509
00510 void dots::LBAction()
00511 {
00512 if (LBpressed)
00513 {
00514 int w = highArea.x - lowArea.x + 1;
00515 int h = highArea.y - lowArea.y + 1;
00516
00517 limitValue2.set(0, int(value1 / 2));
00518 value2 = limitValue2.intForceLimit(value2);
00519
00520 int newX, newY;
00521 if (mode == 1)
00522 {
00523 for (int by = 0; by < int(1.0 * h / value1 + 1); by++)
00524 {
00525 for (int bx = 0; bx < int(1.0 * w / value1 + 1); bx++)
00526 {
00527 int lowX, lowY, highX, highY;
00528
00529 lowX = int(lowArea.x + bx*value1);
00530 lowY = int(lowArea.y + by*value1);
00531 highX = int(lowX + value1);
00532 highY = int(lowY + value1);
00533
00534 if (highX > highArea.x)
00535 highX = highArea.x;
00536 if (highY > highArea.y)
00537 highY = highArea.y;
00538
00539 for (int y = 0; y < value1; y++)
00540 {
00541 for (int x = 0; x < value1; x++)
00542 {
00543 newX = int(lowArea.x + bx*value1 + x);
00544 newY = int(lowArea.y + by*value1 + y);
00545 if (newX >= lowArea.x && newX <= highArea.x && newY >= lowArea.y && newY <= highArea.y)
00546 {
00547 img->data[newX + img->width * newY] = imageRgbaInterpolateColors((1.0 * x / value1), (1.0 * y / value1),
00548 temp->data[lowX + img->width * lowY],
00549 temp->data[highX + img->width * lowY],
00550 temp->data[lowX + img->width * highY],
00551 temp->data[highX + img->width * highY]);
00552 }
00553 }
00554 }
00555 }
00556 }
00557 }
00558 if (mode == 2)
00559 {
00560 imageRgbaSetArea(img, lowArea.x, lowArea.y, highArea.x + 1, highArea.y + 1, myColor);
00561 }
00562 for (int by = 0; by < int(1.0 * h / value1 + 2); by++)
00563 {
00564 for (int bx = 0; bx < int(1.0 * w / value1 + 2); bx++)
00565 {
00566
00567 for (int y = int(-value2); y < int(value2); y++)
00568 {
00569 float xValue = sqrt((value2*value2) - (y*y));
00570 for (int x = int(-xValue); x < int(xValue); x++)
00571 {
00572 newX = int(lowArea.x + bx*value1 + x);
00573 newY = int(lowArea.y + by*value1 + y);
00574 int location = newX + img->width * newY;
00575 if ((newX >= lowArea.x) && (newX <= highArea.x) && (newY >= lowArea.y) && (newY <= highArea.y))
00576 img->data[location] = temp->data[location];
00577 }
00578 }
00579 }
00580 }
00581 }
00582 }
00583
00584 void dots::changeMode(char _mode)
00585 {
00586 mode = _mode;
00587 if (mode == 1)
00588 glutSetWindowTitle("Paint Application | Dots | Mode 1: Interpolated");
00589 else if (mode == 2)
00590 glutSetWindowTitle("Paint Application | Dots | Mode 2: Colorized");
00591
00592 if (!LBpressed)
00593 {
00594 LBpressed = true;
00595 this->LBAction();
00596 LBpressed = false;
00597 }
00598 else
00599 this->LBAction();
00600 }
00601
00603
00605
00606 {
00607 glutSetWindowTitle("Paint Application | RGB-Dots");
00608
00609 startup(_img, _temp, _temp2, _hud, _menu, _bArea, _lowArea, _highArea);
00610
00611 value1 = 10;
00612 if ((highArea.x - lowArea.x + 1) > (highArea.y - lowArea.y + 1))
00613 limitValue1.set(2, int((highArea.x - lowArea.x + 1) / 5));
00614 else
00615 limitValue1.set(2, int((highArea.y - lowArea.y + 1) / 5));
00616
00617 numModes = 2;
00618 mode = 1;
00619
00620 imageRgbaCopy(img, temp);
00621
00622 this->changeMode(1);
00623 }
00624
00625 void rgbdots::LBAction()
00626 {
00627 if (LBpressed)
00628 {
00629 int w = highArea.x - lowArea.x + 1;
00630 int h = highArea.y - lowArea.y + 1;
00631
00632 if (mode == 1)
00633 imageRgbaSetArea(img, lowArea.x, lowArea.y, highArea.x+1, highArea.y+1, (Rgba){0, 0, 0, 255});
00634 else if (mode == 2)
00635 imageRgbaSetArea(img, lowArea.x, lowArea.y, highArea.x+1, highArea.y+1, (Rgba){255, 255, 255, 255});
00636
00637 for (int by = 0; by < int(1.0 * h / value1 + 1); by++)
00638 {
00639 for (int bx = 0; bx < int(1.0 * w / value1 + 1); bx++)
00640 {
00641 int R = 0, G = 0, B = 0, count = 0;
00642 int newX, newY;
00643
00644 for (int y = 0; y < value1; y++)
00645 {
00646 newY = int(lowArea.y + by*value1 + y);
00647 if ((newY >= lowArea.y) && (newY <= highArea.y))
00648 {
00649 for (int x = 0; x < value1; x++)
00650 {
00651 newX = int(lowArea.x + bx*value1 + x);
00652
00653 if ((newX >= lowArea.x) && (newX <= highArea.x))
00654 {
00655 count++;
00656 int location = newX + img->width * newY;
00657 R += temp->data[location].r;
00658 G += temp->data[location].g;
00659 B += temp->data[location].b;
00660 }
00661 }
00662 }
00663 }
00664
00665 if (count != 0)
00666 {
00667 R = limitRGBA.intForceLimit(R / count);
00668 G = limitRGBA.intForceLimit(G / count);
00669 B = limitRGBA.intForceLimit(B / count);
00670 }
00671 point offset;
00672 float radius, xValue;
00673
00674 if (mode == 1)
00675 {
00676
00677 offset.set(int(value1 / 4.0), int(value1 / 4.0));
00678 radius = sqrt(value1*value1 * (1.0 * R / 255)) / sqrt(M_PI);
00679 for (int y = int(offset.y - radius); y < int(offset.y + radius); y++)
00680 {
00681 xValue = sqrt((radius*radius) - ((y - offset.y)*(y - offset.y)));
00682 for (int x = int(offset.x - xValue); x < int(offset.x + xValue); x++)
00683 {
00684 newX = int(lowArea.x + bx*value1 + x);
00685 newY = int(lowArea.y + by*value1 + y);
00686 int location = newX + img->width * newY;
00687 if ((newY >= lowArea.y) && (newY <= highArea.y) && (newX >= lowArea.x) && (newX <= highArea.x))
00688 img->data[location].r = 255;
00689 }
00690 }
00691
00692
00693 offset.set(int(value1 / 4.0 * 3.0), 0);
00694 radius = sqrt(value1*value1 * (1.0 * G / 255)) / sqrt(M_PI);
00695 for (int y = int(offset.y - radius); y < int(offset.y + radius); y++)
00696 {
00697 xValue = sqrt((radius*radius) - ((y - offset.y)*(y - offset.y)));
00698 for (int x = int(offset.x - xValue); x < int(offset.x + xValue); x++)
00699 {
00700 newX = int(lowArea.x + bx*value1 + x);
00701 newY = int(lowArea.y + by*value1 + y);
00702 int location = newX + img->width * newY;
00703 if ((newY >= lowArea.y) && (newY <= highArea.y) && (newX >= lowArea.x) && (newX <= highArea.x))
00704 img->data[location].g = 255;
00705 }
00706 }
00707
00708
00709 offset.set(int(value1 / 2.0), int(value1 / 4.0 * 3.0));
00710 radius = sqrt(value1*value1 * (1.0 * B / 255)) / sqrt(M_PI);
00711 for (int y = int(offset.y - radius); y < int(offset.y + radius); y++)
00712 {
00713 xValue = sqrt((radius*radius) - ((y - offset.y)*(y - offset.y)));
00714 for (int x = int(offset.x - xValue); x < int(offset.x + xValue); x++)
00715 {
00716 newX = int(lowArea.x + bx*value1 + x);
00717 newY = int(lowArea.y + by*value1 + y);
00718 int location = newX + img->width * newY;
00719 if ((newY >= lowArea.y) && (newY <= highArea.y) && (newX >= lowArea.x) && (newX <= highArea.x))
00720 img->data[location].b = 255;
00721 }
00722 }
00723 }
00724 else if (mode == 2)
00725 {
00726
00727 offset.set(int(value1 / 4.0), int(value1 / 4.0));
00728 radius = sqrt(value1*value1 * (1.0 * (255-R) / 255)) / sqrt(M_PI);
00729 for (int y = int(offset.y - radius); y < int(offset.y + radius); y++)
00730 {
00731 xValue = sqrt((radius*radius) - ((y - offset.y)*(y - offset.y)));
00732 for (int x = int(offset.x - xValue); x < int(offset.x + xValue); x++)
00733 {
00734 newX = int(lowArea.x + bx*value1 + x);
00735 newY = int(lowArea.y + by*value1 + y);
00736 int location = newX + img->width * newY;
00737 if ((newY >= lowArea.y) && (newY <= highArea.y) && (newX >= lowArea.x) && (newX <= highArea.x))
00738 img->data[location].r = 0;
00739 }
00740 }
00741
00742
00743 offset.set(int(value1 / 4.0 * 3.0), 0);
00744 radius = sqrt(value1*value1 * (1.0 * (255-G) / 255)) / sqrt(M_PI);
00745 for (int y = int(offset.y - radius); y < int(offset.y + radius); y++)
00746 {
00747 xValue = sqrt((radius*radius) - ((y - offset.y)*(y - offset.y)));
00748 for (int x = int(offset.x - xValue); x < int(offset.x + xValue); x++)
00749 {
00750 newX = int(lowArea.x + bx*value1 + x);
00751 newY = int(lowArea.y + by*value1 + y);
00752 int location = newX + img->width * newY;
00753 if ((newY >= lowArea.y) && (newY <= highArea.y) && (newX >= lowArea.x) && (newX <= highArea.x))
00754 img->data[location].g = 0;
00755 }
00756 }
00757
00758
00759 offset.set(int(value1 / 2.0), int(value1 / 4.0 * 3.0));
00760 radius = sqrt(value1*value1 * (1.0 * (255-B) / 255)) / sqrt(M_PI);
00761 for (int y = int(offset.y - radius); y < int(offset.y + radius); y++)
00762 {
00763 xValue = sqrt((radius*radius) - ((y - offset.y)*(y - offset.y)));
00764 for (int x = int(offset.x - xValue); x < int(offset.x + xValue); x++)
00765 {
00766 newX = int(lowArea.x + bx*value1 + x);
00767 newY = int(lowArea.y + by*value1 + y);
00768 int location = newX + img->width * newY;
00769 if ((newY >= lowArea.y) && (newY <= highArea.y) && (newX >= lowArea.x) && (newX <= highArea.x))
00770 img->data[location].b = 0;
00771 }
00772 }
00773 }
00774 }
00775 }
00776 }
00777 }
00778
00779
00780 void rgbdots::changeMode(char _mode)
00781 {
00782 mode = _mode;
00783 if (mode == 1)
00784 glutSetWindowTitle("Paint Application | RGB-Dots | Mode 1: Additive");
00785 else if (mode == 2)
00786 glutSetWindowTitle("Paint Application | RGB-Dots | Mode 2: Subtractive");
00787
00788 if (!LBpressed)
00789 {
00790 LBpressed = true;
00791 this->LBAction();
00792 LBpressed = false;
00793 }
00794 else
00795 this->LBAction();
00796 }
00797
00799
00801
00802 {
00803 glutSetWindowTitle("Paint Application | Lines");
00804
00805 startup(_img, _temp, _temp2, _hud, _menu, _bArea, _lowArea, _highArea);
00806
00807 value1 = 50;
00808 limitValue1.set(1, 200);
00809
00810 imageRgbaCopy(img, temp);
00811
00812 numModes = 2;
00813 mode = 1;
00814
00815 this->changeMode(1);
00816 }
00817
00818 void lines::LBAction()
00819 {
00820 if (LBpressed)
00821 {
00822 if (mode == 1)
00823 {
00824 for (int iy = lowArea.y; iy <= highArea.y; iy++)
00825 {
00826 int x = lowArea.x, length = 0;
00827 while (x < highArea.x)
00828 {
00829 x += length;
00830 length = int(fmod(rand(), value1)) + 1;
00831 int R = 0, G = 0, B = 0, count = 0;
00832 for (int ix = x; (ix < (x + length)) && (ix <= highArea.x); ix++)
00833 {
00834 count++;
00835 int location = ix + img->width * iy;
00836 R += temp->data[location].r;
00837 G += temp->data[location].g;
00838 B += temp->data[location].b;
00839 }
00840 if (count != 0)
00841 {
00842 R = limitRGBA.intForceLimit(R / count);
00843 G = limitRGBA.intForceLimit(G / count);
00844 B = limitRGBA.intForceLimit(B / count);
00845 }
00846 for (int ix = x; (ix < (x + length)) && (ix <= highArea.x); ix++)
00847 {
00848 int location = ix + img->width * iy;
00849 img->data[location] = (Rgba){R, G, B, 255};
00850 }
00851 }
00852 }
00853 }
00854 if (mode == 2)
00855 {
00856 for (int ix = lowArea.x; ix <= highArea.x; ix++)
00857 {
00858 int y = lowArea.y, length = 0;
00859 while (y < highArea.y)
00860 {
00861 y += length;
00862 length = int(fmod(rand(), value1)) + 1;
00863 int R = 0, G = 0, B = 0, count = 0;
00864 for (int iy = y; (iy < (y + length)) && (iy <= highArea.y); iy++)
00865 {
00866 count++;
00867 int location = ix + img->width * iy;
00868 R += temp->data[location].r;
00869 G += temp->data[location].g;
00870 B += temp->data[location].b;
00871 }
00872 if (count != 0)
00873 {
00874 R = limitRGBA.intForceLimit(R / count);
00875 G = limitRGBA.intForceLimit(G / count);
00876 B = limitRGBA.intForceLimit(B / count);
00877 }
00878 for (int iy = y; (iy < (y + length)) && (iy <= highArea.y); iy++)
00879 {
00880 int location = ix + img->width * iy;
00881 img->data[location] = (Rgba){R, G, B, 255};
00882 }
00883 }
00884 }
00885 }
00886 }
00887 }
00888
00889
00890 void lines::changeMode(char _mode)
00891 {
00892 mode = _mode;
00893 if (mode == 1)
00894 glutSetWindowTitle("Paint Application | Lines | Mode 1: Horizontal");
00895 else if (mode == 2)
00896 glutSetWindowTitle("Paint Application | Lines | Mode 2: Vertical");
00897
00898 if (!LBpressed)
00899 {
00900 LBpressed = true;
00901 this->LBAction();
00902 LBpressed = false;
00903 }
00904 else
00905 this->LBAction();
00906 }
00907
00909
00911
00912 {
00913 glutSetWindowTitle("Paint Application | Noise");
00914
00915 startup(_img, _temp, _temp2, _hud, _menu, _bArea, _lowArea, _highArea);
00916
00917 value1 = 100;
00918 limitValue1.set(0, 100);
00919 value2 = 50;
00920 limitValue2.set(0, 100);
00921
00922 bColorMenu = true;
00923 myColor = (Rgba){64, 64, 192, 255};
00924
00925 imageRgbaCopy(img, temp);
00926
00927 numModes = 2;
00928 this->changeMode(1);
00929 }
00930
00931 void noise::colorChangeAction()
00932 {
00933 if (!LBpressed)
00934 {
00935 LBpressed = true;
00936 this->LBAction();
00937 LBpressed = false;
00938 }
00939 else
00940 this->LBAction();
00941 }
00942
00943 void noise::LBAction()
00944 {
00945 if (LBpressed)
00946 {
00947 for (int y = lowArea.y; y <= highArea.y; y++)
00948 {
00949 for (int x = lowArea.x; x <= highArea.x; x++)
00950 {
00951 int random = rand() % 100;
00952 int location = x + img->width * y;
00953 if (random < value1)
00954 {
00955 float opacity = value2 / 100;
00956 if (mode == 1)
00957 {
00958 img->data[location].r = limitRGBA.intForceLimit((1 - opacity) * temp->data[location].r + opacity * (rand() % 256));
00959 img->data[location].g = limitRGBA.intForceLimit((1 - opacity) * temp->data[location].g + opacity * (rand() % 256));
00960 img->data[location].b = limitRGBA.intForceLimit((1 - opacity) * temp->data[location].b + opacity * (rand() % 256));
00961 }
00962 if (mode == 2)
00963 {
00964 img->data[location].r = limitRGBA.intForceLimit((1 - opacity) * temp->data[location].r + opacity * (limitRGBA.intForceLimit(myColor.r + (rand() % 256))));
00965 img->data[location].g = limitRGBA.intForceLimit((1 - opacity) * temp->data[location].g + opacity * (limitRGBA.intForceLimit(myColor.g + (rand() % 256))));
00966 img->data[location].b = limitRGBA.intForceLimit((1 - opacity) * temp->data[location].b + opacity * (limitRGBA.intForceLimit(myColor.b + (rand() % 256))));
00967 }
00968 }
00969 else
00970 img->data[location] = temp->data[location];
00971 }
00972 }
00973 }
00974 }
00975
00976 void noise::changeMode(char _mode)
00977 {
00978 mode = _mode;
00979 if (mode == 1)
00980 glutSetWindowTitle("Paint Application | Noise | Mode 1: Random");
00981 else if (mode == 2)
00982 glutSetWindowTitle("Paint Application | Noise | Mode 2: Colorized");
00983
00984 if (!LBpressed)
00985 {
00986 LBpressed = true;
00987 this->LBAction();
00988 LBpressed = false;
00989 }
00990 else
00991 this->LBAction();
00992 }