Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

/home/landauf/painter/miniproject/effects/geometric.cpp

Go to the documentation of this file.
00001 #include "geometric.h"
00002 
00004 // Ripple                                                                    //
00006 ripple::ripple(ImageRGBA *_img, ImageRGBA *_temp, ImageRGBA *_temp2, ImageRGBA *_hud, ImageRGBA *_menu, bool _bArea, point _lowArea, point _highArea)
00007 {
00008     glutSetWindowTitle("Paint Application | Ripple");
00009 
00010     startup(_img, _temp, _temp2, _hud, _menu, _bArea, _lowArea, _highArea);
00011 
00012     imageRgbaCopy(img, temp);
00013     
00014     numModes = 4;
00015     value2 = 10; // strength
00016     limitValue2.set(1, 50);
00017     value1 = 5; // length
00018     limitValue1.set(1, 50);
00019     refresh = false;
00020     interpolate = false;
00021     inActionState = false;
00022     
00023     this->changeMode(1);
00024 }
00025 
00026 void ripple::idleAction()
00027 {
00028     const int w = img->width;
00029     const int h = img->height;
00030     float newX, newY;
00031     if ((LBpressed || refresh) && mouse.x >= 0 && mouse.y >= 0 && mouse.x <= w && mouse.y <= h)
00032     {
00033         for (int y = lowArea.y; y <= highArea.y; y++)
00034         {
00035             for (int x = lowArea.x; x <= highArea.x; x++)
00036             {
00037                 if (mode == 1)
00038                 {
00039                     newX = x + value2 * sin(sqrt((x - mouse.x)*(x - mouse.x) + (y - mouse.y)*(y - mouse.y)) / value1);
00040                     newY = y + value2 * sin(sqrt((x - mouse.x)*(x - mouse.x) + (y - mouse.y)*(y - mouse.y)) / value1);
00041                 }
00042                 else if (mode == 2)
00043                 {
00044                     newX = x + value2 * sin((x - mouse.x) / value1);
00045                     newY = y;
00046                 }
00047                 else if (mode == 3)
00048                 {
00049                     newX = x;
00050                     newY = y + value2 * sin((y - mouse.y) / value1);
00051                 }
00052                 else if (mode == 4)
00053                 {
00054                     newX = x + value2 * sin((x - mouse.x) / value1);
00055                     newY = y + value2 * sin((y - mouse.y) / value1);
00056                 }
00057 
00058                 if (newX < lowArea.x)
00059                     newX = lowArea.x;
00060                 if (newY < lowArea.y)
00061                     newY = lowArea.y;
00062                 if (newX > highArea.x)
00063                     newX = highArea.x;
00064                 if (newY > highArea.y)
00065                     newY = highArea.y;
00066                     
00067                 if (interpolate)
00068                     img->data[int(x + w*y)] = imageRgbaInterpolate(temp, newX, newY);
00069                 else
00070                     img->data[int(x + w*y)] = temp->data[int(newX) + w*int(newY)];
00071 
00072 //                img->data[int(x + w*y)] = temp->data[int(1.0*x/w/2.0+0.5+1)+w*int(1.0*y/w/2.0+0.5)];
00073 //                img->data[int(x + w*y)] = imageRgbaInterpolate(temp, 1+1.0*x/w, 1.0*y/w);
00074             }
00075         }
00076         refresh = false;
00077     }
00078 }
00079 
00080 void ripple::keyRIGHT()
00081 {
00082     value1 += 1;
00083     if (value1 >= limitValue1.high)
00084         value1 = limitValue1.high;
00085 }
00086 
00087 void ripple::keyLEFT()
00088 {
00089     value1 -= 1;
00090     if (value1 <= limitValue1.low)
00091         value1 = limitValue1.low;    
00092 }
00093 
00094 void ripple::keyUP()
00095 {
00096     value2 += 2;
00097     if (value2 > limitValue2.high)
00098         value2 = limitValue2.high;
00099 }
00100 
00101 void ripple::keyDOWN()
00102 {
00103     value2 -= 2;
00104     if (value2 < limitValue2.low)
00105         value2 = limitValue2.low;
00106 }
00107 
00108 void ripple::changeMode(char _mode)
00109 {
00110     mode = _mode;
00111     if (mode == 1)
00112         glutSetWindowTitle("Paint Application | Ripple | Mode 1: Radial");
00113     else if (mode == 2)
00114         glutSetWindowTitle("Paint Application | Ripple | Mode 2: Vertical");
00115     else if (mode == 3)
00116         glutSetWindowTitle("Paint Application | Ripple | Mode 3: Horizontal");
00117     else if (mode == 4)
00118         glutSetWindowTitle("Paint Application | Ripple | Mode 4: Crossed");
00119         
00120     if (!LBpressed)
00121     {
00122         LBpressed = true;
00123         this->idleAction();
00124         LBpressed = false;
00125     }
00126     else
00127         this->idleAction();
00128 }
00129         
00130 
00132 // Bubble                                                                    //
00134 bubble::bubble(ImageRGBA *_img, ImageRGBA *_temp, ImageRGBA *_temp2, ImageRGBA *_hud, ImageRGBA *_menu, bool _bArea, point _lowArea, point _highArea)
00135 {
00136     glutSetWindowTitle("Paint Application | Bubble");
00137 
00138     startup(_img, _temp, _temp2, _hud, _menu, _bArea, _lowArea, _highArea);
00139 
00140     imageRgbaCopy(img, temp);
00141     
00142     numModes = 4;
00143     value2 = 25; // strength
00144     limitValue2.set(1, 250);
00145     value1 = 100; // length
00146     limitValue1.set(10, 1000);
00147     refresh = false;
00148     interpolate = false;
00149     inActionState = false;
00150     
00151     this->changeMode(1);
00152 }
00153 
00154 void bubble::idleAction()
00155 {
00156     const int w = img->width;
00157     const int h = img->height;
00158     float newX, newY, distance, factor;
00159     if ((LBpressed || refresh) && mouse.x >= 0 && mouse.y >= 0 && mouse.x <= w && mouse.y <= h)
00160     {
00161         for (int y = lowArea.y; y <= highArea.y; y++)
00162         {
00163             for (int x = lowArea.x; x <= highArea.x; x++)
00164             {
00165                 if (mode == 1 || mode == 2)
00166                     distance = sqrt((x - mouse.x)*(x - mouse.x) + (y - mouse.y)*(y - mouse.y));
00167                 else if (mode == 3)
00168                     distance = (x - mouse.x);
00169                 else if (mode == 4)
00170                     distance = (y - mouse.y);
00171                 
00172                 newX = x;
00173                 newY = y;
00174                 if ((fabs(distance) <= value1))
00175                 {
00176                     if (mode == 1)
00177                     {
00178                         factor = pow((distance / value1), (value2 / 20.0));
00179                         newX = mouse.x + (x - mouse.x) * factor;
00180                         newY = mouse.y + (y - mouse.y) * factor;
00181                     }
00182                     else if (mode == 2)
00183                     {
00184                         factor = cbrt((distance / value1));
00185                         newX = mouse.x + (x - mouse.x) / factor;
00186                         newY = mouse.y + (y - mouse.y) / factor;
00187                     }
00188                     else if (mode == 3)
00189                     {
00190                         factor = pow((fabs(distance) / value1), (value2 / 20.0));
00191                         newX = mouse.x + distance * factor;
00192                     }
00193                     else if (mode == 4)
00194                     {
00195                         factor = pow((fabs(distance) / value1), (value2 / 20.0));
00196                         newY = mouse.y + distance * factor;
00197                     }
00198                     
00199                     if (newX < lowArea.x)
00200                         newX = lowArea.x;
00201                     if (newY < lowArea.y)
00202                         newY = lowArea.y;
00203                     if (newX > highArea.x)
00204                         newX = highArea.x;
00205                     if (newY > highArea.y)
00206                         newY = highArea.y;
00207                 }
00208                 
00209                 if (interpolate && (distance <= value1))
00210                     img->data[int(x + w*y)] = imageRgbaInterpolate(temp, newX, newY);
00211                 else
00212                     img->data[int(x + w*y)] = temp->data[int(newX) + w*int(newY)];
00213             }
00214         }
00215         refresh = false;
00216     }
00217 }
00218 
00219 void bubble::keyRIGHT()
00220 {
00221     value1 += 5;
00222     if (value1 >= limitValue1.high)
00223         value1 = limitValue1.high;
00224 }
00225 
00226 void bubble::keyLEFT()
00227 {
00228     value1 -= 5;
00229     if (value1 <= limitValue1.low)
00230         value1 = limitValue1.low;    
00231 }
00232 
00233 void bubble::keyUP()
00234 {
00235     value2 += 5;
00236     if (value2 > limitValue2.high)
00237         value2 = limitValue2.high;
00238 }
00239 
00240 void bubble::keyDOWN()
00241 {
00242     value2 -= 5;
00243     if (value2 < limitValue2.low)
00244         value2 = limitValue2.low;
00245 }
00246 
00247 void bubble::changeMode(char _mode)
00248 {
00249     mode = _mode;
00250     if (mode == 1)
00251         glutSetWindowTitle("Paint Application | Bubble | Mode 1: Convex");
00252     else if (mode == 2)
00253         glutSetWindowTitle("Paint Application | Bubble | Mode 2: Concave");
00254     else if (mode == 3)
00255         glutSetWindowTitle("Paint Application | Bubble | Mode 3: Vertical");
00256     else if (mode == 4)
00257         glutSetWindowTitle("Paint Application | Bubble | Mode 4: Horizontal");
00258         
00259     if (!LBpressed)
00260     {
00261         LBpressed = true;
00262         this->idleAction();
00263         LBpressed = false;
00264     }
00265     else
00266         this->idleAction();
00267 }
00268 
00270 // Lens                                                                      //
00272 lens::lens(ImageRGBA *_img, ImageRGBA *_temp, ImageRGBA *_temp2, ImageRGBA *_hud, ImageRGBA *_menu, bool _bArea, point _lowArea, point _highArea)
00273 {
00274     glutSetWindowTitle("Paint Application | Lens");
00275 
00276     startup(_img, _temp, _temp2, _hud, _menu, _bArea, _lowArea, _highArea);
00277 
00278     imageRgbaCopy(img, temp);
00279     
00280     numModes = 4;
00281     value2 = 190; // strength
00282     limitValue2.set(0, 359);
00283     value1 = 100; // length
00284     limitValue1.set(10, 1000);
00285     refresh = false;
00286     interpolate = false;
00287     inActionState = false;
00288     
00289     bColorMenu = true;
00290     myColor = (Rgba){0, 0, 0, 255};
00291     
00292     this->changeMode(1);
00293 }
00294 
00295 void lens::idleAction()
00296 {
00297     const int w = img->width;
00298     const int h = img->height;
00299     float newX, newY, distance, factor;
00300     double angle;
00301     float newValue2 = value2 / 180.0 * M_PI;
00302     
00303     if ((LBpressed || refresh) && mouse.x >= 0 && mouse.y >= 0 && mouse.x <= w && mouse.y <= h)
00304     {
00305         for (int y = lowArea.y; y <= highArea.y; y++)
00306         {
00307             for (int x = lowArea.x; x <= highArea.x; x++)
00308             {
00309                 bool inArea = true;
00310                 distance = sqrt((x - mouse.x)*(x - mouse.x) + (y - mouse.y)*(y - mouse.y));
00311                 newX = x;
00312                 newY = y;
00313                 if (distance <= value1)
00314                 {
00315                     if (mode == 1)
00316                     {
00317                         factor = pow((distance / value1), (newValue2 / 20.0));
00318                         newX = (mouse.x - x);
00319                         newY = (mouse.y - y);
00320                         
00321                         if (newY == 0 && newX > 0)
00322                             angle = M_PI / 2.0;
00323                         else
00324                             angle = atan(newX / newY);
00325                         
00326                         if (newX == 0 && newY == 0)
00327                             angle = 0;
00328                             
00329                         if (newY >= 0)
00330                             angle -= M_PI;
00331     
00332                         angle += newValue2;
00333                         
00334                         newX = mouse.x + sin(angle) * distance;
00335                         newY = mouse.y + cos(angle) * distance;
00336                     }
00337                     else if (mode == 2)
00338                     {
00339                         newValue2 = value2 / 36.0;
00340                         newX = mouse.x + (x - mouse.x) * newValue2;
00341                         newY = mouse.y + (y - mouse.y) * newValue2;
00342                     }
00343                     else if (mode == 3)
00344                     {
00345                         newX = mouse.x + (x - mouse.x) * -1;
00346                     }
00347                     else if (mode == 4)
00348                     {
00349                         newY = mouse.y + (y - mouse.y) * -1;
00350                     }
00351                     
00352                     if (newX < lowArea.x || newY < lowArea.y || newX > highArea.x || newY > highArea.y)
00353                         inArea = false;
00354                 }
00355                 if (inArea)
00356                 {
00357                     if (interpolate && (distance <= value1))
00358                         img->data[int(x + w*y)] = imageRgbaInterpolate(temp, newX, newY);
00359                     else
00360                         img->data[int(x + w*y)] = temp->data[int(newX) + w*int(newY)];
00361                 }
00362                 else
00363                     img->data[int(x + w*y)] = myColor;
00364             }
00365         }
00366         refresh = false;
00367     }
00368 }
00369 
00370 void lens::keyRIGHT()
00371 {
00372     value1 += 5;
00373     if (value1 >= limitValue1.high)
00374         value1 = limitValue1.high;
00375 }
00376 
00377 void lens::keyLEFT()
00378 {
00379     value1 -= 5;
00380     if (value1 <= limitValue1.low)
00381         value1 = limitValue1.low;    
00382 }
00383 
00384 void lens::keyUP()
00385 {
00386     value2 += 5;
00387     if (value2 > limitValue2.high)
00388         value2 = limitValue2.low;
00389 }
00390 
00391 void lens::keyDOWN()
00392 {
00393     value2 -= 5;
00394     if (value2 < limitValue2.low)
00395         value2 = limitValue2.high;
00396 }
00397 
00398 void lens::changeMode(char _mode)
00399 {
00400     mode = _mode;
00401     if (mode == 1)
00402         glutSetWindowTitle("Paint Application | Lens | Mode 1: Turn");
00403     else if (mode == 2)
00404         glutSetWindowTitle("Paint Application | Lens | Mode 2: Zoom");
00405     else if (mode == 3)
00406         glutSetWindowTitle("Paint Application | Lens | Mode 3: Flip vertical");
00407     else if (mode == 4)
00408         glutSetWindowTitle("Paint Application | Lens | Mode 4: Flip horizontal");
00409         
00410     if (!LBpressed)
00411     {
00412         LBpressed = true;
00413         this->idleAction();
00414         LBpressed = false;
00415     }
00416     else
00417         this->idleAction();
00418 }
00419 
00420 
00422 // Twirl                                                                     //
00424 twirl::twirl(ImageRGBA *_img, ImageRGBA *_temp, ImageRGBA *_temp2, ImageRGBA *_hud, ImageRGBA *_menu, bool _bArea, point _lowArea, point _highArea)
00425 {
00426     glutSetWindowTitle("Paint Application | Twirl");
00427 
00428     startup(_img, _temp, _temp2, _hud, _menu, _bArea, _lowArea, _highArea);
00429 
00430     imageRgbaCopy(img, temp);
00431     
00432     numModes = 2;
00433     value2 = 180; // strength
00434     limitValue2.set(-1080, 1080);
00435     value1 = 100; // length
00436     limitValue1.set(10, 1000);
00437     refresh = false;
00438     interpolate = false;
00439     inActionState = false;
00440     
00441     this->changeMode(1);
00442 }
00443 
00444 void twirl::idleAction()
00445 {
00446     int w, h;
00447     float newX, newY, distance, factor;
00448     double angle;
00449     float newValue2 = value2 / 180.0 * M_PI;
00450 
00451     w = img->width;
00452     h = img->height;
00453     if ((mode == 1) && (LBpressed || refresh)&& (mouse.x >= 0 && mouse.y >= 0 && mouse.x <= w && mouse.y <= h))
00454     {
00455         for (int y = lowArea.y; y <= highArea.y; y++)
00456         {
00457             for (int x = lowArea.x; x <= highArea.x; x++)
00458             {
00459                 distance = sqrt((x - mouse.x)*(x - mouse.x) + (y - mouse.y)*(y - mouse.y));
00460                 newX = x;
00461                 newY = y;
00462                 if (distance <= value1)
00463                 {
00464                     factor = pow((distance / value1), (newValue2 / 20.0));
00465                     newX = (mouse.x - x);
00466                     newY = (mouse.y - y);
00467                     
00468                     if (newY == 0 && newX > 0)
00469                         angle = M_PI / 2;
00470                     else
00471                         angle = atan(newX / newY);
00472                     
00473                     if (newX == 0 && newY == 0)
00474                         angle = 0;
00475 
00476                     if (newY >= 0)
00477                         angle += M_PI;
00478                     
00479                     angle += newValue2 * pow((value1 - distance) / value1, 2);
00480 
00481                     newX = mouse.x + sin(angle) * distance;
00482                     newY = mouse.y + cos(angle) * distance;
00483                     
00484                     if (newX < lowArea.x)
00485                         newX = lowArea.x;
00486                     if (newY < lowArea.y)
00487                         newY = lowArea.y;
00488                     if (newX > highArea.x)
00489                         newX = highArea.x;
00490                     if (newY > highArea.y)
00491                         newY = highArea.y;
00492                 }
00493                 if (interpolate && (distance <= value1))
00494                     img->data[int(x + w*y)] = imageRgbaInterpolate(temp, newX, newY);
00495                 else
00496                     img->data[int(x + w*y)] = temp->data[int(newX) + w*int(newY)];
00497             }
00498         }
00499     }
00500     else if ((mode == 2) && (LBpressed || refresh))
00501     {
00502         int numW = int(value1 / 50 + 1);
00503         if (numW == 0)
00504             numW = 1;
00505 
00506         w = (highArea.x - lowArea.x + 1);
00507         h = (highArea.y - lowArea.y + 1);
00508         
00509         float newLength, xLength, yLength;
00510         xLength = w / numW;
00511         yLength = h / numW;
00512         if (w <= h)
00513             newLength = xLength / 2;
00514         else
00515             newLength = yLength / 2;
00516             
00517         for (int wy = 0; wy < numW; wy++)
00518         {
00519             for (int wx = 0; wx < numW; wx++)
00520             {
00521                 for (int y = 0; y < int(yLength); y++)
00522                 {
00523                     for (int x = 0; x < int(xLength); x++)
00524                     {
00525                         distance = sqrt((xLength/2 - x)*(xLength/2 - x) + (yLength/2 - y)*(yLength/2 - y));
00526                         newX = lowArea.x + wx*xLength + x;
00527                         newY = lowArea.y + wy*yLength + y;
00528                         if (distance <= newLength)
00529                         {
00530                             factor = pow((distance / newLength), (newValue2 / 20.0));
00531                             newX = (xLength/2 - x);
00532                             newY = (yLength/2 - y);
00533 
00534                             if (newY == 0 && newX > 0)
00535                                 angle = M_PI / 2;
00536                             else
00537                                 angle = atan(newX / newY);
00538                             
00539                             if (newX == 0 && newY == 0)
00540                                 angle = 0;
00541         
00542                             if (newY >= 0)
00543                                 angle += M_PI;
00544                                      
00545                             angle += newValue2 * pow((newLength - distance) / newLength, 2); //90.0/180.0*M_PI;
00546         
00547                             newX = lowArea.x + wx*xLength + xLength/2 + sin(angle) * distance;
00548                             newY = lowArea.y + wy*yLength + yLength/2 + cos(angle) * distance;
00549                             
00550                             if (newX < lowArea.x)
00551                                 newX = lowArea.x;
00552                             if (newY < lowArea.y)
00553                                 newY = lowArea.y;
00554                             if (newX > highArea.x)
00555                                 newX = highArea.x;
00556                             if (newY > highArea.y)
00557                                 newY = highArea.y;
00558                         }
00559                         img->data[int((lowArea.x + wx*xLength+x) + img->width*(lowArea.y + wy*yLength+y))] = imageRgbaInterpolate(temp, newX, newY);
00560                     }
00561                 }
00562             }
00563         }
00564     }
00565     refresh = false;
00566 }
00567 
00568 void twirl::keyRIGHT()
00569 {
00570     if (mode == 1)
00571         value1 += 10;
00572     else if (mode == 2)
00573     {
00574         value1 += 50;
00575         imageRgbaCopy(temp, img);
00576     }
00577     if (value1 >= limitValue1.high)
00578         value1 = limitValue1.high;    
00579 }
00580 
00581 void twirl::keyLEFT()
00582 {
00583     if (mode == 1)
00584         value1 -= 10;
00585     else if (mode == 2)
00586     {
00587         value1 -= 50;
00588         imageRgbaCopy(temp, img);
00589     }
00590     if (value1 <= limitValue1.low)
00591         value1 = limitValue1.low;
00592 }
00593 
00594 void twirl::keyUP()
00595 {
00596     value2 += 30;
00597     if (value2 > limitValue2.high)
00598         value2 = limitValue2.high;
00599 }
00600 
00601 void twirl::keyDOWN()
00602 {
00603     value2 -= 30;
00604     if (value2 < limitValue2.low)
00605         value2 = limitValue2.low;
00606 }
00607 
00608 void twirl::changeMode(char _mode)
00609 {
00610     mode = _mode;
00611     if (mode == 1)
00612         glutSetWindowTitle("Paint Application | Twirl | Mode 1: Single Twirl");
00613     else if (mode == 2)
00614         glutSetWindowTitle("Paint Application | Twirl | Mode 2: Multiple Twirl");
00615         
00616     if (!LBpressed)
00617     {
00618         LBpressed = true;
00619         this->idleAction();
00620         LBpressed = false;
00621     }
00622     else
00623         this->idleAction();
00624 }
00625 
00627 // Wave                                                                      //
00629 wave::wave(ImageRGBA *_img, ImageRGBA *_temp, ImageRGBA *_temp2, ImageRGBA *_hud, ImageRGBA *_menu, bool _bArea, point _lowArea, point _highArea)
00630 {
00631     glutSetWindowTitle("Paint Application | Wave");
00632 
00633     startup(_img, _temp, _temp2, _hud, _menu, _bArea, _lowArea, _highArea);
00634 
00635     imageRgbaCopy(img, temp);
00636     
00637     numModes = 3;
00638     value2 = 10; // strength
00639     limitValue2.set(1, 50);
00640     value1 = 5; // length
00641     limitValue1.set(1, 50);
00642     refresh = false;
00643     interpolate = false;
00644     inActionState = false;
00645     
00646     this->changeMode(1);
00647 }
00648 
00649 void wave::idleAction()
00650 {
00651     const int w = img->width;
00652     const int h = img->height;
00653     float newX, newY;
00654     if ((LBpressed || refresh) && mouse.x >= 0 && mouse.y >= 0 && mouse.x <= w && mouse.y <= h)
00655     {
00656         for (int y = lowArea.y; y <= highArea.y; y++)
00657         {
00658             for (int x = lowArea.x; x <= highArea.x; x++)
00659             {
00660                 if (mode == 1)
00661                 {
00662                     newX = x + value2 * sin((y - mouse.y) / value1);
00663                     newY = y;
00664                 }
00665                 else if (mode == 2)
00666                 {
00667                     newX = x;
00668                     newY = y + value2 * sin((x - mouse.x) / value1);
00669                 }
00670                 else if (mode == 3)
00671                 {
00672                     newX = x + value2 * sin((y - mouse.y) / value1);
00673                     newY = y + value2 * sin((x - mouse.x) / value1);
00674                 }
00675 
00676                 if (newX < lowArea.x)
00677                     newX = lowArea.x;
00678                 if (newY < lowArea.y)
00679                     newY = lowArea.y;
00680                 if (newX > highArea.x)
00681                     newX = highArea.x;
00682                 if (newY > highArea.y)
00683                     newY = highArea.y;
00684                     
00685                 if (interpolate)
00686                     img->data[int(x + w*y)] = imageRgbaInterpolate(temp, newX, newY);
00687                 else
00688                     img->data[int(x + w*y)] = temp->data[int(newX) + w*int(newY)];
00689 
00690 //                img->data[int(x + w*y)] = temp->data[int(1.0*x/w/2.0+0.5+1)+w*int(1.0*y/w/2.0+0.5)];
00691 //                img->data[int(x + w*y)] = imageRgbaInterpolate(temp, 1+1.0*x/w, 1.0*y/w);
00692             }
00693         }
00694         refresh = false;
00695     }
00696 }
00697 
00698 void wave::keyLEFT()
00699 {
00700     value1 -= 1;
00701     if (value1 <= limitValue1.low)
00702         value1 = limitValue1.low;    
00703 }
00704 
00705 void wave::keyRIGHT()
00706 {
00707     value1 += 1;
00708     if (value1 >= limitValue1.high)
00709         value1 = limitValue1.high;
00710 }
00711 
00712 void wave::keyUP()
00713 {
00714     value2 += 2;
00715     if (value2 > limitValue2.high)
00716         value2 = limitValue2.high;
00717 }
00718 
00719 void wave::keyDOWN()
00720 {
00721     value2 -= 2;
00722     if (value2 < limitValue2.low)
00723         value2 = limitValue2.low;
00724 }
00725 
00726 void wave::changeMode(char _mode)
00727 {
00728     mode = _mode;
00729     if (mode == 1)
00730         glutSetWindowTitle("Paint Application | Wave | Mode 1: Horizontal");
00731     else if (mode == 2)
00732         glutSetWindowTitle("Paint Application | Wave | Mode 2: Vertical");
00733     else if (mode == 3)
00734         glutSetWindowTitle("Paint Application | Wave | Mode 3: Full");
00735         
00736     if (!LBpressed)
00737     {
00738         LBpressed = true;
00739         this->idleAction();
00740         LBpressed = false;
00741     }
00742     else
00743         this->idleAction();
00744 }
00745 
00747 // Buttonize                                                                 //
00749 buttonize::buttonize(ImageRGBA *_img, ImageRGBA *_temp, ImageRGBA *_temp2, ImageRGBA *_hud, ImageRGBA *_menu, bool _bArea, point _lowArea, point _highArea)
00750 {
00751     glutSetWindowTitle("Paint Application | Buttonize");
00752 
00753     startup(_img, _temp, _temp2, _hud, _menu, _bArea, _lowArea, _highArea);
00754 
00755     imageRgbaCopy(img, temp);
00756     
00757     if ((highArea.x - lowArea.x + 1) < (highArea.y - lowArea.y + 1))
00758         limitValue1.set(0, int((highArea.x - lowArea.x + 1) / 2));
00759     else
00760         limitValue1.set(0, int((highArea.y - lowArea.y + 1) / 2));
00761     value1 = int(limitValue1.high / 4); // length
00762 
00763     numModes = 2;
00764     
00765     value2 = 50; // opacity
00766     limitValue2.set(0, 100);
00767     refresh = false;
00768     bColorMenu = true;
00769     myColor = (Rgba){0, 0, 0, 255};    
00770 
00771     this->changeMode(1);
00772 }
00773 
00774 
00775 void buttonize::colorChangeAction()
00776 {
00777     if (!LBpressed)
00778     {
00779         LBpressed = true;
00780         this->LBAction();
00781         LBpressed = false;
00782     }
00783     else
00784         this->LBAction();
00785 }
00786 
00787 void buttonize::idleAction()
00788 {
00789     this->LBAction();
00790 }
00791 
00792 void buttonize::LBAction()
00793 {
00794     const int w = img->width;
00795     const int h = img->height;
00796     if ((LBpressed || refresh) && mouse.x >= 0 && mouse.y >= 0 && mouse.x <= w && mouse.y <= h)
00797     {
00798         for (int y = lowArea.y; y <= highArea.y; y++)
00799         {
00800             for (int x = lowArea.x; x <= highArea.x; x++)
00801             {
00802                 int location = x + img->width * y;
00803                 float position, opacity;
00804 
00805                 if ((y-lowArea.y) < value1 && (y-lowArea.y) <= (x-lowArea.x) && (y-lowArea.y) < (highArea.x - x))
00806                 {
00807                     if (mode == 1)
00808                     {
00809                         position = 1 - (y-lowArea.y)/value1;
00810                         opacity =  (value2/100 * position);
00811                         img->data[location].r = limitRGBA.intForceLimit(((1 - opacity) * temp->data[location].r) + (opacity * myColor.r));
00812                         img->data[location].g = limitRGBA.intForceLimit(((1 - opacity) * temp->data[location].g) + (opacity * myColor.g));
00813                         img->data[location].b = limitRGBA.intForceLimit(((1 - opacity) * temp->data[location].b) + (opacity * myColor.b));
00814                     }
00815                     if (mode == 2)
00816                     {
00817                         opacity = value2 / 100;
00818                         img->data[location].r = limitRGBA.intForceLimit(((1 - opacity) * temp->data[location].r) + (opacity * (myColor.r + 50)));
00819                         img->data[location].g = limitRGBA.intForceLimit(((1 - opacity) * temp->data[location].g) + (opacity * (myColor.g + 50)));
00820                         img->data[location].b = limitRGBA.intForceLimit(((1 - opacity) * temp->data[location].b) + (opacity * (myColor.b + 50)));
00821                     }
00822                 }
00823                 else if (y >= (highArea.y - value1) && (y-highArea.y) > (x-highArea.x) && (highArea.y - y) <= (x - lowArea.x))
00824                 {
00825                     if (mode == 1)
00826                     {
00827                         position = (y-(highArea.y - value1))/value1;
00828                         opacity =  (value2/100 * position);
00829                         img->data[location].r = limitRGBA.intForceLimit(((1 - opacity) * temp->data[location].r) + (opacity * myColor.r));
00830                         img->data[location].g = limitRGBA.intForceLimit(((1 - opacity) * temp->data[location].g) + (opacity * myColor.g));
00831                         img->data[location].b = limitRGBA.intForceLimit(((1 - opacity) * temp->data[location].b) + (opacity * myColor.b));
00832                     }
00833                     if (mode == 2)
00834                     {
00835                         opacity = value2 / 100;
00836                         img->data[location].r = limitRGBA.intForceLimit(((1 - opacity) * temp->data[location].r) + (opacity * (myColor.r - 50)));
00837                         img->data[location].g = limitRGBA.intForceLimit(((1 - opacity) * temp->data[location].g) + (opacity * (myColor.g - 50)));
00838                         img->data[location].b = limitRGBA.intForceLimit(((1 - opacity) * temp->data[location].b) + (opacity * (myColor.b - 50)));
00839                     }
00840                 }
00841                 else if ((x-lowArea.x) < value1)
00842                 {
00843                     if (mode == 1)
00844                     {
00845                         position = 1 - (x-lowArea.x)/value1;
00846                         opacity =  (value2/100 * position);
00847                         img->data[location].r = limitRGBA.intForceLimit(((1 - opacity) * temp->data[location].r) + (opacity * myColor.r));
00848                         img->data[location].g = limitRGBA.intForceLimit(((1 - opacity) * temp->data[location].g) + (opacity * myColor.g));
00849                         img->data[location].b = limitRGBA.intForceLimit(((1 - opacity) * temp->data[location].b) + (opacity * myColor.b));
00850                     }
00851                     if (mode == 2)
00852                     {
00853                         opacity = value2 / 100;
00854                         img->data[location].r = limitRGBA.intForceLimit(((1 - opacity) * temp->data[location].r) + (opacity * (myColor.r + 20)));
00855                         img->data[location].g = limitRGBA.intForceLimit(((1 - opacity) * temp->data[location].g) + (opacity * (myColor.g + 20)));
00856                         img->data[location].b = limitRGBA.intForceLimit(((1 - opacity) * temp->data[location].b) + (opacity * (myColor.b + 20)));
00857                     }
00858                 }
00859                 else if (x >= (highArea.x - value1))
00860                 {
00861                     if (mode == 1)
00862                     {
00863                         position = (x-(highArea.x - value1))/value1;
00864                         opacity =  (value2/100 * position);
00865                         img->data[location].r = limitRGBA.intForceLimit(((1 - opacity) * temp->data[location].r) + (opacity * myColor.r));
00866                         img->data[location].g = limitRGBA.intForceLimit(((1 - opacity) * temp->data[location].g) + (opacity * myColor.g));
00867                         img->data[location].b = limitRGBA.intForceLimit(((1 - opacity) * temp->data[location].b) + (opacity * myColor.b));
00868                     }
00869                     if (mode == 2)
00870                     {
00871                         opacity = value2 / 100;
00872                         img->data[location].r = limitRGBA.intForceLimit(((1 - opacity) * temp->data[location].r) + (opacity * (myColor.r - 20)));
00873                         img->data[location].g = limitRGBA.intForceLimit(((1 - opacity) * temp->data[location].g) + (opacity * (myColor.g - 20)));
00874                         img->data[location].b = limitRGBA.intForceLimit(((1 - opacity) * temp->data[location].b) + (opacity * (myColor.b - 20)));
00875                     }
00876                 }
00877                 else
00878                     img->data[location] = temp->data[location];
00879             }
00880         }
00881         refresh = false;
00882     }
00883 }
00884 
00885 void buttonize::keyRIGHT()
00886 {
00887     value1 += 1;
00888     if (value1 > limitValue1.high)
00889         value1 = limitValue1.high;
00890 }
00891 
00892 void buttonize::keyLEFT()
00893 {
00894     value1 -= 1;
00895     if (value1 < limitValue1.low)
00896         value1 = limitValue1.low;    
00897 }
00898 
00899 void buttonize::keyUP()
00900 {
00901     value2 += 5;
00902     if (value2 > limitValue2.high)
00903         value2 = limitValue2.high;
00904 }
00905 
00906 void buttonize::keyDOWN()
00907 {
00908     value2 -= 5;
00909     if (value2 < limitValue2.low)
00910         value2 = limitValue2.low;
00911 }
00912 
00913 void buttonize::changeMode(char _mode)
00914 {
00915     mode = _mode;
00916     if (mode == 1)
00917         glutSetWindowTitle("Paint Application | Buttonize | Mode 1: Floating");
00918     else if (mode == 2)
00919         glutSetWindowTitle("Paint Application | Buttonize | Mode 2: Fixed");
00920         
00921     if (!LBpressed)
00922     {
00923         LBpressed = true;
00924         this->LBAction();
00925         LBpressed = false;
00926     }
00927     else
00928         this->LBAction();
00929 }   
00930      
00932 // Glass                                                                     //
00934 glass::glass(ImageRGBA *_img, ImageRGBA *_temp, ImageRGBA *_temp2, ImageRGBA *_hud, ImageRGBA *_menu, bool _bArea, point _lowArea, point _highArea)
00935 {
00936     glutSetWindowTitle("Paint Application | Glass");
00937 
00938     startup(_img, _temp, _temp2, _hud, _menu, _bArea, _lowArea, _highArea);
00939 
00940     value1 = 40;
00941     if ((highArea.x - lowArea.x + 1) > (highArea.y - lowArea.y + 1))
00942         limitValue1.set(5, (highArea.x - lowArea.x + 1));
00943     else
00944         limitValue1.set(5, (highArea.y - lowArea.y + 1));
00945     value2 = 10;
00946     limitValue2.set(0, 50);
00947     numModes = 8;
00948     mode = 1;
00949     imageRgbaCopy(img, temp);
00950     bColorMenu = true;
00951     myColor = (Rgba){255, 255, 255, 255};
00952     myAngleXY = 1.0/4.0*M_PI;
00953     myAngleZ = 1.0/8.0*M_PI;
00954     myStrength = 0.0;
00955    
00956     this->changeMode(1);
00957 }
00958 
00959 void glass::colorChangeAction()
00960 {
00961     if (!LBpressed)
00962     {
00963         LBpressed = true;
00964         this->LBAction();
00965         LBpressed = false;
00966     }
00967     else
00968         this->LBAction();
00969 }
00970 
00971 void glass::drawLightningMenu()
00972 {
00973     int newX, newY, drawX, drawY;
00974     for (int y = 0; y < 150; y++)
00975     {
00976         for (int x = 0; x < 150; x++)
00977         {
00978             if (x < img->width && y < img->height)
00979                 img->data[x + img->width * y] = (Rgba){0, 0, 0, 255};
00980         }
00981     }
00982     imageRgbaDrawEllipse(img, 75, 75, 50, 50, (Rgba){255, 255, 255, 255});
00983     newX = int(75 + sin(myAngleXY + M_PI) * cos(myAngleZ)*50);
00984     newY = int(75 + cos(myAngleXY + M_PI) * cos(myAngleZ)*50);
00985     imageRgbaDrawLine(img, newX, newY, int(75 + sin(myAngleXY + M_PI) * 50), int(75 + cos(myAngleXY + M_PI) * 50), (Rgba){255, 255, 255, 255});
00986 
00987     for (int y = int(-7); y < int(7); y++)
00988     {
00989         float xValue = sqrt((7*7) - (y*y)) + 1;
00990         for (int x = int(-xValue); x < int(xValue); x++)
00991         {
00992             drawX = newX + x;
00993             drawY = newY + y;
00994             int location = drawX + img->width * drawY;
00995             if ((drawY >= 0) && (drawY < img->width) && (drawX >= 0) && (drawX <= img->height))
00996                 img->data[location] = (Rgba){limitRGBA.intForceLimit(255 / 2 * myStrength), limitRGBA.intForceLimit(255 / 2 * myStrength), limitRGBA.intForceLimit(255 / 2 * myStrength), 255};
00997         }
00998     }
00999 
01000     imageRgbaDrawEllipse(img, newX, newY, 7, 7, (Rgba){255, 255, 255, 255});
01001 }
01002 
01003 void glass::LBAction()
01004 {
01005     if (LBpressed)
01006     {
01007         int w = highArea.x - lowArea.x + 1;
01008         int h = highArea.y - lowArea.y + 1;
01009         
01010         for (int by = 0; by < int(1.0 * h / value1 + 1); by++)
01011         {
01012             for (int bx = 0; bx < int(1.0 * w / value1 + 1); bx++)
01013             {
01014                 for (int y = 0; y < value1; y++)
01015                 {
01016                     for (int x = 0; x < value1; x++)
01017                     {
01018                         float newX, newY, oldX, oldY;
01019                         int dO, dU, dL, dR, M;
01020                         float dVertical, dHorizontal;
01021                         newX = (1.0 * x / value1 * 20.0);
01022                         newY = (1.0 * y / value1 * 20.0);
01023                         
01024                         M = imageRgbaInterpolateSubImage(menu, newX, newY, 20, 20, (100 - mode + 1) * 400);
01025 
01026                         dO = imageRgbaInterpolateSubImage(menu, newX, newY - 1, 20, 20, (100 - mode + 1) * 400) - M;
01027                         dU = M - imageRgbaInterpolateSubImage(menu, newX, newY + 1, 20, 20, (100 - mode + 1) * 400);
01028                         dL = imageRgbaInterpolateSubImage(menu, newX - 1, newY, 20, 20, (100 - mode + 1) * 400) - M;
01029                         dR = M - imageRgbaInterpolateSubImage(menu, newX + 1, newY, 20, 20, (100 - mode + 1) * 400);
01030                         
01031                         dHorizontal = (1.0 * (dL + dR) / 2.0);
01032                         dVertical = (1.0 * (dO + dU) / 2.0);
01033                         
01034                         dHorizontal = (dHorizontal) / 255.0 * value2 * 20;
01035                         dVertical = (dVertical) / 255.0 * value2 * 20;
01036 /*                        
01037                         if (dHorizontal > 255) { dHorizontal = 255; }
01038                         if (dHorizontal < -255) { dHorizontal = -255; }
01039                         if (dVertical > 255) { dVertical = 255; }
01040                         if (dVertical < -255) { dVertical = -255; }
01041 */
01042                         oldX = (lowArea.x + bx*value1 + x);
01043                         oldY = (lowArea.y + by*value1 + y);
01044                         newX = (oldX + dHorizontal);
01045                         newY = (oldY + dVertical);
01046 
01047                         if (newX < lowArea.x) { newX = lowArea.x; }
01048                         if (newY < lowArea.y) { newY = lowArea.y; }
01049                         if (newX > highArea.x) { newX = highArea.x; }
01050                         if (newY > highArea.y) { newY = highArea.y; }
01051 
01052                         if (oldX < lowArea.x) { oldX = lowArea.x; }
01053                         if (oldY < lowArea.y) { oldY = lowArea.y; }
01054                         if (oldX > highArea.x) { oldX = highArea.x; }
01055                         if (oldY > highArea.y) { oldY = highArea.y; }
01056 
01057                         if (myStrength > 0)
01058                         {
01059                             float angleXY;
01060     
01061                             // XY-Angle
01062                             // calculating the XY-Angle of each pixel (XY-Angle means something like north/south/west/east)
01063                             // the XY-Angle depends on dVertical and dHorizontal, which are the pitch in y and x direction
01064                             if (dVertical == 0 && dHorizontal > 0)
01065                                 angleXY = M_PI / 2.0;
01066                             else
01067                                 angleXY = atan(dHorizontal / dVertical);
01068                             if (dHorizontal == 0 && dVertical == 0)
01069                                 angleXY = 0;
01070                             if (dVertical >= 0)
01071                                 angleXY -= M_PI;
01072                             if (angleXY < 0) { angleXY += 2 * M_PI; }
01073                             if (angleXY > (2 * M_PI)) { angleXY -= 2 * M_PI; }
01074 
01075 //                            dAXY = fabs(myAngleXY - angleXY);
01076 //                            if (dAXY > M_PI)
01077 //                                dAXY = ((2*M_PI) - dAXY);
01078 
01079                             // Z-Angle
01080                             // now the same with the Z-Angle - a flat pixel got Z-Angle = 0, a pixle in a upright 'wall' got Z-Angle = 90°
01081                             float angleZ;
01082                             float pitch = (fabs(dHorizontal) + fabs(dVertical)) / 2;
01083                             if (pitch < 2)
01084                                 pitch = 0; // avoiding some noise
01085                             pitch /= (3*value2);   // pitch is something between 0 and 255, and I randomly define a value as a degree of ~35° (because pitch = 1 gives us (below) a Z-angle of ~35°)
01086                             // angle between 2 vectors: [1, 1, steigung] and [0, 0, 1] (normalvector of the image)
01087                             angleZ = asin(((pitch)/(sqrt(2 + pitch*pitch))));
01088 
01089                             if (angleZ == 0) // if the pixel is flat, we dont need a XY-angle
01090                                 angleXY = myAngleXY;
01091 
01092                             angleZ = (M_PI / 2) - angleZ; // we need the angle inverted
01093                             
01094                             float dFinal = 0;
01095                             // angle between 2 vectors: 1) pixel direction with angleXY and angleZ, 2) light-direction with myAngleXY and myAngleZ
01096                             dFinal = asin(fabs((cos(angleXY)*cos(myAngleXY)+sin(angleXY)*sin(myAngleXY)+tan(angleZ)*tan(myAngleZ))/(sqrt(cos(angleXY)*cos(angleXY) + sin(angleXY)*sin(angleXY) + tan(angleZ)*tan(angleZ)) * sqrt(cos(myAngleXY)*cos(myAngleXY) + sin(myAngleXY)*sin(myAngleXY) + tan(myAngleZ)*tan(myAngleZ)))));
01097                             dFinal = (dFinal / (M_PI / 2));
01098 
01099 //                          dAXY = (dAXY / (1*M_PI));
01100 //                          dAZ = (dAZ / (0.5*M_PI));
01101                             
01102                             
01103 //                            img->data[int(oldX) + img->width*int(oldY)].r = limitRGBA.intForceLimit(127 + steigung / 512 * 255);
01104 //                            img->data[int(oldX) + img->width*int(oldY)].g = limitRGBA.intForceLimit(127 + steigung / 512 * 255);
01105 //                            img->data[int(oldX) + img->width*int(oldY)].b = limitRGBA.intForceLimit(127 + steigung / 512 * 255);
01106 
01107 //                            img->data[int(oldX) + img->width*int(oldY)].r = limitRGBA.intForceLimit(angleXY / (2*M_PI) * 255);
01108 //                            img->data[int(oldX) + img->width*int(oldY)].g = limitRGBA.intForceLimit(angleXY / (2*M_PI) * 255);
01109 //                            img->data[int(oldX) + img->width*int(oldY)].b = limitRGBA.intForceLimit(angleXY / (2*M_PI) * 255);
01110     
01111 //                            img->data[int(oldX) + img->width*int(oldY)].r = limitRGBA.intForceLimit((1 - dAXY / (1*M_PI)) * 255);
01112 //                            img->data[int(oldX) + img->width*int(oldY)].g = limitRGBA.intForceLimit((1 - dAXY / (1*M_PI)) * 255);
01113 //                            img->data[int(oldX) + img->width*int(oldY)].b = limitRGBA.intForceLimit((1 - dAXY / (1*M_PI)) * 255);
01114     
01115 //                            img->data[int(oldX) + img->width*int(oldY)].r = limitRGBA.intForceLimit(angleZ / (0.5*M_PI) * 255);
01116 //                            img->data[int(oldX) + img->width*int(oldY)].g = limitRGBA.intForceLimit(angleZ / (0.5*M_PI) * 255);
01117 //                            img->data[int(oldX) + img->width*int(oldY)].b = limitRGBA.intForceLimit(angleZ / (0.5*M_PI) * 255);
01118     
01119 //                            img->data[int(oldX) + img->width*int(oldY)].r = limitRGBA.intForceLimit((dAZ / (0.5*M_PI)) * 255);
01120 //                            img->data[int(oldX) + img->width*int(oldY)].g = limitRGBA.intForceLimit((dAZ / (0.5*M_PI)) * 255);
01121 //                            img->data[int(oldX) + img->width*int(oldY)].b = limitRGBA.intForceLimit((dAZ / (0.5*M_PI)) * 255);
01122                             
01123 //                            img->data[int(oldX) + img->width*int(oldY)].r = limitRGBA.intForceLimit(dAXY * (dAZ/2) * 255 * 2);
01124 //                            img->data[int(oldX) + img->width*int(oldY)].g = limitRGBA.intForceLimit(dAXY * (dAZ/2) * 255 * 2);
01125 //                            img->data[int(oldX) + img->width*int(oldY)].b = limitRGBA.intForceLimit(dAXY * (dAZ/2) * 255 * 2);
01126     
01127 //                            img->data[int(oldX) + img->width*int(oldY)].r = limitRGBA.intForceLimit(dFinal * 255);
01128 //                            img->data[int(oldX) + img->width*int(oldY)].g = limitRGBA.intForceLimit(dFinal * 255);
01129 //                            img->data[int(oldX) + img->width*int(oldY)].b = limitRGBA.intForceLimit(dFinal * 255);
01130 
01131 //                            img->data[int(oldX) + img->width*int(oldY)].r = limitRGBA.intForceLimit(255 - (1-dAZ) * 255 - dAXY * 255);
01132 //                            img->data[int(oldX) + img->width*int(oldY)].g = limitRGBA.intForceLimit(255 - (1-dAZ) * 255 - dAXY * 255);
01133 //                            img->data[int(oldX) + img->width*int(oldY)].b = limitRGBA.intForceLimit(255 - (1-dAZ) * 255 - dAXY * 255);
01134 /*    
01135                             int locationNEW = int(newX) + img->width*int(newY);
01136                             int locationOLD = int(oldX) + img->width*int(oldY);
01137                             img->data[locationOLD].r = limitRGBA.intForceLimit(temp->data[locationNEW].r + myStrength * dAXY * (dAZ/2) * myColor.r * 2);
01138                             img->data[locationOLD].g = limitRGBA.intForceLimit(temp->data[locationNEW].g + myStrength * dAXY * (dAZ/2) * myColor.g * 2);
01139                             img->data[locationOLD].b = limitRGBA.intForceLimit(temp->data[locationNEW].b + myStrength * dAXY * (dAZ/2) * myColor.b * 2);
01140 */
01141     
01142                             int locationNEW = int(newX) + img->width*int(newY);
01143                             int locationOLD = int(oldX) + img->width*int(oldY);
01144                             img->data[locationOLD].r = limitRGBA.intForceLimit(temp->data[locationNEW].r + myStrength * dFinal * myColor.r);
01145                             img->data[locationOLD].g = limitRGBA.intForceLimit(temp->data[locationNEW].g + myStrength * dFinal * myColor.g);
01146                             img->data[locationOLD].b = limitRGBA.intForceLimit(temp->data[locationNEW].b + myStrength * dFinal * myColor.b);
01147 
01148                         }
01149                         else
01150                         {
01151 
01152 //                            if (interpolate)
01153 //                                img->data[int(oldX) + img->width*int(oldY)] = imageRgbaInterpolate(temp, newX, newY);
01154 //                            else
01155                                 img->data[int(oldX) + img->width*int(oldY)] = temp->data[int(newX) + img->width*int(newY)];
01156 
01157                         }
01158                     }
01159                 }
01160             }
01161         }
01162     }
01163 }
01164 
01165 void glass::key(unsigned char _key)
01166 {
01167     inAction = inActionState;
01168 
01169     if (_key == ' ')
01170         bMenu = !bMenu;
01171 
01172     if (_key == 127)
01173     {
01174         myStrength -= 0.25;
01175         if (myStrength < 0)
01176             myStrength = 0;
01177 
01178         this->drawLightningMenu();
01179     }
01180 }
01181 
01182 void glass::specialKey(int _key)
01183 {
01184     inAction = inActionState;
01185 
01186     if (_key <= numModes)
01187         this->changeMode(_key);
01188         
01189     if (_key == GLUT_KEY_LEFT || _key == GLUT_KEY_RIGHT || _key == GLUT_KEY_UP || _key == GLUT_KEY_DOWN)
01190         this->changeValue(_key);
01191         
01192     if (_key == GLUT_KEY_PAGE_DOWN)
01193     {
01194         myStrength += 0.25;
01195         if (myStrength > 2)
01196             myStrength = 2;
01197 
01198         this->drawLightningMenu();
01199     }
01200 
01201     if (_key == GLUT_KEY_INSERT)
01202     {
01203         myAngleXY += (M_PI / 16);
01204         if (myAngleXY > (2*M_PI))
01205             myAngleXY = 0;
01206 
01207         this->drawLightningMenu();
01208     }
01209     if (_key == GLUT_KEY_PAGE_UP)
01210     {
01211         myAngleXY -= (M_PI / 16);
01212         if (myAngleXY < 0)
01213             myAngleXY = (2*M_PI);
01214 
01215         this->drawLightningMenu();
01216     }
01217 
01218     if (_key == GLUT_KEY_HOME)
01219     {
01220         myAngleZ += (M_PI / 32);
01221         if (myAngleZ > (0.5*M_PI))
01222             myAngleZ = (0.5*M_PI);
01223 
01224         this->drawLightningMenu();
01225     }
01226     if (_key == GLUT_KEY_END)
01227     {
01228         myAngleZ -= (M_PI / 32);
01229         if (myAngleZ < (M_PI / 16))
01230             myAngleZ = (M_PI / 16);
01231 
01232         this->drawLightningMenu();
01233     }
01234 }
01235 
01236 void glass::changeMode(char _mode)
01237 {
01238     mode = _mode;
01239     if (mode == 1)
01240     {
01241         value1 = 50;
01242         glutSetWindowTitle("Paint Application | Glass | Mode 1: Rough Glass");
01243     }
01244     else if (mode == 2)
01245     {
01246         value1 = 50;
01247         glutSetWindowTitle("Paint Application | Glass | Mode 2: Glass Plates");
01248     }
01249     else if (mode == 3)
01250     {
01251         value1 = 30;
01252         glutSetWindowTitle("Paint Application | Glass | Mode 3: Glass Blocks");
01253     }
01254     else if (mode == 4)
01255     {
01256         value1 = 20;
01257         glutSetWindowTitle("Paint Application | Glass | Mode 4: Curly Glass");
01258     }
01259     else if (mode == 5)
01260     {
01261         value1 = 40;
01262         glutSetWindowTitle("Paint Application | Glass | Mode 5: Glass Rings");
01263     }
01264     else if (mode == 6)
01265     {
01266         value1 = 20;
01267         glutSetWindowTitle("Paint Application | Glass | Mode 6: Dotted Glass");
01268     }
01269     else if (mode == 7)
01270     {
01271         value1 = 50;
01272         glutSetWindowTitle("Paint Application | Glass | Mode 7: Puzzle");
01273     }
01274     else if (mode == 8)
01275     {
01276         value1 = 60;
01277         glutSetWindowTitle("Paint Application | Glass | Mode 8: Custom");
01278     }
01279 
01280     if (!LBpressed)
01281     {
01282         LBpressed = true;
01283         this->LBAction();
01284         LBpressed = false;
01285     }
01286     else
01287         this->LBAction();
01288 }

Generated on Mon Jan 30 09:13:02 2006 for Painter Framework by doxygen1.2.18