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

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

Go to the documentation of this file.
00001 #include "classes.h"
00002 
00004 // Point                                                                     //
00006 point::point(int _x, int _y)
00007 {
00008     x = _x;
00009     y = _y;
00010 }
00011 
00012 bool point::checkArea(point _low, point _high)
00013 {
00014     return (x >= _low.x && x <= _high.x && y >= _low.y && y <= _high.y);
00015 }
00016 
00017 void point::set(int _x, int _y)
00018 {
00019     x = _x;
00020     y = _y;
00021 }
00022 
00024 // Limit                                                                     //
00026 limit::limit(int _low, int _high)
00027 {
00028     low = _low;
00029     high = _high;
00030 }
00031 
00032 bool limit::checkLimit(float _value)
00033 {
00034     return (_value >= low && _value <= high);
00035 }
00036 
00037 float limit::forceLimit(float _value)
00038 {
00039     if (_value > high)
00040         return high;
00041     else if (_value < low)
00042         return low;
00043     else
00044         return _value;
00045 }
00046 
00047 int limit::intForceLimit(float _value)
00048 {
00049     if (_value > high)
00050         return int(high);
00051     else if (_value < low)
00052         return int(low);
00053     else
00054         return int(_value);
00055 }
00056 
00057 void limit::set(int _low, int _high)
00058 {
00059     low = _low;
00060     high = _high;
00061 }
00062 
00064 // Matrix                                                                    //
00066 matrix::matrix(float *_E, char _dimension, short int _division)
00067 {
00068     dimension = _dimension;
00069     division = _division;
00070     this->convertMatrix(_E);
00071 }
00072 
00073 matrix::~matrix()
00074 {   
00075 }
00076 
00077 void matrix::convertMatrix(float *_E)
00078 {
00079     for (int y = 0; y < 11; y++)
00080     {
00081         for (int x = 0; x < 11; x++)
00082         {
00083             if (x >= (5-dimension) && x <= (5+dimension) && y >= (5-dimension) && y <= (5+dimension))
00084                 E[y][x] = *(_E + (dimension*2+1)*(y-5+dimension) + (x-5+dimension));
00085             else
00086                 E[y][x] = 0;
00087         }
00088     }
00089 }
00090 
00091 Rgba applyMatrix(ImageRGBA *_img, matrix *_M, int _x, int _y, point _lowArea, point _highArea)
00092 {
00093     if (_img && _M)
00094     {
00095         int mx, my, location;
00096         float R = 0, G = 0, B = 0;
00097         
00098         for (int y = (5 - _M->dimension); y <= (5 + _M->dimension); y++)
00099         {
00100             for (int x = (5 - _M->dimension); x <= (5 + _M->dimension); x++)
00101             {
00102                 mx = _x - 5 + x;
00103                 my = _y - 5 + y;
00104                 
00105                 if (mx < _lowArea.x)
00106                     mx = _lowArea.x;
00107                 if (my < _lowArea.y)
00108                     my = _lowArea.y;
00109                 if (mx > _highArea.x)
00110                     mx = _highArea.x;
00111                 if (my > _highArea.y)
00112                     my = _highArea.y;
00113                 
00114                 location = mx + _img->width * my;
00115                 
00116                 R += _M->E[y][x] * _img->data[location].r;
00117                 G += _M->E[y][x] * _img->data[location].g;
00118                 B += _M->E[y][x] * _img->data[location].b;
00119             }
00120         }
00121         
00122         R = (R / _M->division);
00123         G = (G / _M->division);
00124         B = (B / _M->division);
00125         
00126         if (R > 255) { R = 255; }
00127         else if (R < 0) { R = 0; }
00128         if (G > 255) { G = 255; }
00129         else if (G < 0) { G = 0; }
00130         if (B > 255) { B = 255; }
00131         else if (B < 0) { B = 0; }
00132              
00133         return (Rgba){int(R), int(G), int(B), 255};
00134     }
00135     else
00136         return (Rgba){0, 0, 0, 255};
00137 }
00138 
00140 // Effect                                                                    //
00142 effect::effect(ImageRGBA *_img, ImageRGBA *_temp, ImageRGBA *_temp2, ImageRGBA *_hud, ImageRGBA *_menu, bool _bArea, point _lowArea, point _highArea)
00143 {
00144     glutSetWindowTitle("Paint Application");
00145     startup(_img, _temp, _temp2, _hud, _menu, _bArea, _lowArea, _highArea);
00146 }
00147 
00148 effect::~effect()
00149 {
00150 }
00151 
00152 void effect::startup(ImageRGBA *_img, ImageRGBA *_temp, ImageRGBA *_temp2, ImageRGBA *_hud, ImageRGBA *_menu, bool _bArea, point _lowArea, point _highArea)
00153 {
00154     if (_img)
00155     {
00156         img = _img;
00157         temp = _temp;
00158         temp2 = _temp2;
00159         hud = _hud;
00160         menu = _menu;
00161         
00162         display = img;
00163         limitX.set(0, img->width - 1);
00164         limitY.set(0, img->height - 1);
00165     
00166         mouse.set(0, 0);
00167         LBpressed = false;
00168         RBpressed = false;
00169         inAction = false;
00170         inActionState = true;
00171         
00172         bMenu = false;
00173         bColorMenu = false;
00174 //        bProgressBar = false;
00175         myColor = (Rgba){0, 0, 0, 255};
00176 //        progress = 0;
00177         mode = 1;
00178         numModes = 1;
00179         value1 = 0;
00180         value2 = 0;
00181         limitValue1.set(0, 0);
00182         limitValue2.set(0, 0);
00183         areaColorOffset = 0;
00184         limitRGBA.set(0, 255);
00185 
00186         myAngleXY = 0;
00187         myAngleZ = 0;
00188         myStrength = 0;
00189         
00190         
00191         for (int i = 0; i < 10; i++)
00192             M[i] = 0;
00193         
00194         bArea = _bArea;    
00195         if (bArea)
00196         {
00197             lowArea.set(_lowArea.x, _lowArea.y);
00198             highArea.set(_highArea.x, _highArea.y);
00199         }
00200         else
00201         {
00202             lowArea.set(0, 0);
00203             highArea.set(img->width - 1, img->height - 1);
00204         }
00205     }
00206 }
00207 
00208 void effect::idle()
00209 {
00210     inAction = inActionState;
00211 
00212     this->idleAction();
00213     this->showHud();
00214 }
00215 
00216 void effect::idleAction()
00217 {
00218 }
00219 
00220 void effect::move()
00221 {
00222     inAction = inActionState;
00223 
00224     bool buttonPressed = false;
00225     if (bMenu && LBpressed)
00226         buttonPressed = this->useMenu(false);
00227 
00228     this->moveAction();
00229     this->showHud();
00230 }
00231 
00232 void effect::moveAction()
00233 {
00234 }
00235 
00236 void effect::LB(bool _state)
00237 {
00238     bool buttonPressed = false;
00239     if (bMenu && _state)
00240         buttonPressed = this->useMenu(true);
00241 
00242     if (!buttonPressed)
00243         LBpressed = _state;
00244     
00245     this->LBAction();
00246 }
00247 
00248 void effect::LBAction()
00249 {
00250 }
00251 
00252 void effect::RB(bool _state)
00253 {
00254     RBpressed = _state;
00255     
00256     this->RBAction();
00257 }
00258 
00259 void effect::RBAction()
00260 {
00261 }
00262 
00263 void effect::colorChangeAction()
00264 {
00265 }
00266 
00267 void effect::key(unsigned char _key)
00268 {
00269     inAction = inActionState;
00270 
00271     if (_key == ' ')
00272         bMenu = !bMenu;
00273 }
00274 
00275 void effect::specialKey(int _key)
00276 {
00277     inAction = inActionState;
00278 
00279     if (_key <= numModes)
00280         this->changeMode(_key);
00281         
00282     if (_key == GLUT_KEY_LEFT || _key == GLUT_KEY_RIGHT || _key == GLUT_KEY_UP || _key == GLUT_KEY_DOWN)
00283         this->changeValue(_key);
00284 }
00285 
00286 void effect::setXY(float _x, float _y)
00287 {
00288     mouse.set(int(_x), int(_y));
00289 }
00290 
00291 void effect::changeMode(char _mode)
00292 {
00293     mode = _mode;
00294 }
00295 
00296 void effect::changeValue(char _key)
00297 {
00298 }
00299 
00300 void effect::showArea()
00301 {
00302     areaColorOffset++;
00303     areaColorOffset %= 8;
00304     lowArea.x = int(limitX.forceLimit(lowArea.x));
00305     lowArea.y = int(limitY.forceLimit(lowArea.y));
00306     highArea.x = int(limitX.forceLimit(highArea.x));
00307     highArea.y = int(limitY.forceLimit(highArea.y));
00308 
00309 //    imageRgbaInvertLine(img, hud, lowArea.x, lowArea.y + 1, lowArea.x, highArea.y - 1);
00310     imageRgbaDrawVerticalAreaLine(hud, lowArea.y, highArea.y, lowArea.x, areaColorOffset);
00311 //    imageRgbaInvertLine(img, hud, lowArea.x, lowArea.y, highArea.x, lowArea.y);
00312     imageRgbaDrawHorizontalAreaLine(hud, lowArea.x, highArea.x, lowArea.y, areaColorOffset);
00313 //    imageRgbaInvertLine(img, hud, highArea.x, lowArea.y + 1, highArea.x, highArea.y - 1);
00314     imageRgbaDrawVerticalAreaLine(hud, lowArea.y, highArea.y, highArea.x, areaColorOffset);
00315 //    imageRgbaInvertLine(img, hud, lowArea.x, highArea.y, highArea.x, highArea.y);
00316     imageRgbaDrawHorizontalAreaLine(hud, lowArea.x, highArea.x, highArea.y, areaColorOffset);
00317 }
00318 
00319 void effect::showMenu()
00320 {
00321     int offsetX, offsetY, number;
00322     
00323 // Zeile 1
00324     // save
00325     number = 0;
00326     offsetX = 0;    offsetY = 0;
00327     for (int y = 0; y < 20; y++)
00328         for (int x = 0; x < 20; x++)
00329             hud->data[limitX.intForceLimit(x + offsetX) + hud->width * limitY.intForceLimit(y + offsetY)] = menu->data[number * 400 + x + 20 * y];
00330     
00331     // backwards
00332     number = 1;
00333     offsetX = 20;    offsetY = 0;
00334     for (int y = 0; y < 20; y++)
00335         for (int x = 0; x < 20; x++)
00336             hud->data[limitX.intForceLimit(x + offsetX) + hud->width * limitY.intForceLimit(y + offsetY)] = menu->data[number * 400 + x + 20 * y];
00337             
00338     // zoom in
00339     number = 7;
00340     offsetX = 50;    offsetY = 0;
00341     for (int y = 0; y < 20; y++)
00342         for (int x = 0; x < 20; x++)
00343             hud->data[limitX.intForceLimit(x + offsetX) + hud->width * limitY.intForceLimit(y + offsetY)] = menu->data[number * 400 + x + 20 * y];
00344             
00345     // zoom out
00346     number = 8;
00347     offsetX = 70;    offsetY = 0;
00348     for (int y = 0; y < 20; y++)
00349         for (int x = 0; x < 20; x++)
00350             hud->data[limitX.intForceLimit(x + offsetX) + hud->width * limitY.intForceLimit(y + offsetY)] = menu->data[number * 400 + x + 20 * y];
00351             
00352     // close
00353     number = 2;
00354     offsetX = hud->width - 20;  offsetY = 0;
00355     for (int y = 0; y < 20; y++)
00356         for (int x = 0; x < 20; x++)
00357             hud->data[limitX.intForceLimit(x + offsetX) + hud->width * limitY.intForceLimit(y + offsetY)] = menu->data[number * 400 + x + 20 * y];
00358 
00359 // Zeile 2
00360     // paint
00361     number = 3;
00362     offsetX = 0;    offsetY = 30;
00363     for (int y = 0; y < 20; y++)
00364         for (int x = 0; x < 20; x++)
00365             hud->data[limitX.intForceLimit(x + offsetX) + hud->width * limitY.intForceLimit(y + offsetY)] = menu->data[number * 400 + x + 20 * y];
00366             
00367     // selection
00368     number = 4;
00369     offsetX = 20;    offsetY = 30;
00370     for (int y = 0; y < 20; y++)
00371         for (int x = 0; x < 20; x++)
00372             hud->data[limitX.intForceLimit(x + offsetX) + hud->width * limitY.intForceLimit(y + offsetY)] = menu->data[number * 400 + x + 20 * y];
00373             
00374     // scroll
00375     number = 5;
00376     offsetX = 40;    offsetY = 30;
00377     for (int y = 0; y < 20; y++)
00378         for (int x = 0; x < 20; x++)
00379             hud->data[limitX.intForceLimit(x + offsetX) + hud->width * limitY.intForceLimit(y + offsetY)] = menu->data[number * 400 + x + 20 * y];
00380             
00381     // telescope
00382     number = 6;
00383     offsetX = 60;    offsetY = 30;
00384     for (int y = 0; y < 20; y++)
00385         for (int x = 0; x < 20; x++)
00386             hud->data[limitX.intForceLimit(x + offsetX) + hud->width * limitY.intForceLimit(y + offsetY)] = menu->data[number * 400 + x + 20 * y];
00387 
00388 // Zeile 3
00389     // brightness
00390     number = 9;
00391     offsetX = 0;    offsetY = 60;
00392     for (int y = 0; y < 20; y++)
00393         for (int x = 0; x < 20; x++)
00394             hud->data[limitX.intForceLimit(x + offsetX) + hud->width * limitY.intForceLimit(y + offsetY)] = menu->data[number * 400 + x + 20 * y];
00395             
00396     // contrast
00397     number = 10;
00398     offsetX = 20;    offsetY = 60;
00399     for (int y = 0; y < 20; y++)
00400         for (int x = 0; x < 20; x++)
00401             hud->data[limitX.intForceLimit(x + offsetX) + hud->width * limitY.intForceLimit(y + offsetY)] = menu->data[number * 400 + x + 20 * y];
00402             
00403     // saturation
00404     number = 11;
00405     offsetX = 40;    offsetY = 60;
00406     for (int y = 0; y < 20; y++)
00407         for (int x = 0; x < 20; x++)
00408             hud->data[limitX.intForceLimit(x + offsetX) + hud->width * limitY.intForceLimit(y + offsetY)] = menu->data[number * 400 + x + 20 * y];
00409             
00410     // hue
00411     number = 12;
00412     offsetX = 60;    offsetY = 60;
00413     for (int y = 0; y < 20; y++)
00414         for (int x = 0; x < 20; x++)
00415             hud->data[limitX.intForceLimit(x + offsetX) + hud->width * limitY.intForceLimit(y + offsetY)] = menu->data[number * 400 + x + 20 * y];
00416             
00417     // colorize
00418     number = 13;
00419     offsetX = 80;    offsetY = 60;
00420     for (int y = 0; y < 20; y++)
00421         for (int x = 0; x < 20; x++)
00422             hud->data[limitX.intForceLimit(x + offsetX) + hud->width * limitY.intForceLimit(y + offsetY)] = menu->data[number * 400 + x + 20 * y];
00423             
00424     // channel
00425     number = 14;
00426     offsetX = 100;    offsetY = 60;
00427     for (int y = 0; y < 20; y++)
00428         for (int x = 0; x < 20; x++)
00429             hud->data[limitX.intForceLimit(x + offsetX) + hud->width * limitY.intForceLimit(y + offsetY)] = menu->data[number * 400 + x + 20 * y];
00430             
00431     // gray
00432     number = 15;
00433     offsetX = 130;    offsetY = 60;
00434     for (int y = 0; y < 20; y++)
00435         for (int x = 0; x < 20; x++)
00436             hud->data[limitX.intForceLimit(x + offsetX) + hud->width * limitY.intForceLimit(y + offsetY)] = menu->data[number * 400 + x + 20 * y];
00437             
00438     // invert
00439     number = 16;
00440     offsetX = 150;    offsetY = 60;
00441     for (int y = 0; y < 20; y++)
00442         for (int x = 0; x < 20; x++)
00443             hud->data[limitX.intForceLimit(x + offsetX) + hud->width * limitY.intForceLimit(y + offsetY)] = menu->data[number * 400 + x + 20 * y];
00444             
00445     // posterize
00446     number = 17;
00447     offsetX = 170;    offsetY = 60;
00448     for (int y = 0; y < 20; y++)
00449         for (int x = 0; x < 20; x++)
00450             hud->data[limitX.intForceLimit(x + offsetX) + hud->width * limitY.intForceLimit(y + offsetY)] = menu->data[number * 400 + x + 20 * y];
00451             
00452     // solarize
00453     number = 18;
00454     offsetX = 190;    offsetY = 60;
00455     for (int y = 0; y < 20; y++)
00456         for (int x = 0; x < 20; x++)
00457             hud->data[limitX.intForceLimit(x + offsetX) + hud->width * limitY.intForceLimit(y + offsetY)] = menu->data[number * 400 + x + 20 * y];
00458             
00459 // Zeile 4
00460     // ripple
00461     number = 19;
00462     offsetX = 0;    offsetY = 80;
00463     for (int y = 0; y < 20; y++)
00464         for (int x = 0; x < 20; x++)
00465             hud->data[limitX.intForceLimit(x + offsetX) + hud->width * limitY.intForceLimit(y + offsetY)] = menu->data[number * 400 + x + 20 * y];
00466             
00467     // bulb
00468     number = 20;
00469     offsetX = 20;    offsetY = 80;
00470     for (int y = 0; y < 20; y++)
00471         for (int x = 0; x < 20; x++)
00472             hud->data[limitX.intForceLimit(x + offsetX) + hud->width * limitY.intForceLimit(y + offsetY)] = menu->data[number * 400 + x + 20 * y];
00473             
00474     // twirl
00475     number = 21;
00476     offsetX = 40;    offsetY = 80;
00477     for (int y = 0; y < 20; y++)
00478         for (int x = 0; x < 20; x++)
00479             hud->data[limitX.intForceLimit(x + offsetX) + hud->width * limitY.intForceLimit(y + offsetY)] = menu->data[number * 400 + x + 20 * y];
00480             
00481     // lens
00482     number = 22;
00483     offsetX = 60;    offsetY = 80;
00484     for (int y = 0; y < 20; y++)
00485         for (int x = 0; x < 20; x++)
00486             hud->data[limitX.intForceLimit(x + offsetX) + hud->width * limitY.intForceLimit(y + offsetY)] = menu->data[number * 400 + x + 20 * y];
00487             
00488     // wave
00489     number = 23;
00490     offsetX = 80;    offsetY = 80;
00491     for (int y = 0; y < 20; y++)
00492         for (int x = 0; x < 20; x++)
00493             hud->data[limitX.intForceLimit(x + offsetX) + hud->width * limitY.intForceLimit(y + offsetY)] = menu->data[number * 400 + x + 20 * y];
00494             
00495     // buttonize
00496     number = 24;
00497     offsetX = 110;    offsetY = 80;
00498     for (int y = 0; y < 20; y++)
00499         for (int x = 0; x < 20; x++)
00500             hud->data[limitX.intForceLimit(x + offsetX) + hud->width * limitY.intForceLimit(y + offsetY)] = menu->data[number * 400 + x + 20 * y];
00501             
00502     // glass
00503     number = 25;
00504     offsetX = 130;    offsetY = 80;
00505     for (int y = 0; y < 20; y++)
00506         for (int x = 0; x < 20; x++)
00507             hud->data[limitX.intForceLimit(x + offsetX) + hud->width * limitY.intForceLimit(y + offsetY)] = menu->data[number * 400 + x + 20 * y];
00508             
00509 // zeile 5
00510     // mosaik
00511     number = 26;
00512     offsetX = 0;    offsetY = 100;
00513     for (int y = 0; y < 20; y++)
00514         for (int x = 0; x < 20; x++)
00515             hud->data[limitX.intForceLimit(x + offsetX) + hud->width * limitY.intForceLimit(y + offsetY)] = menu->data[number * 400 + x + 20 * y];
00516             
00517     // box
00518     number = 27;
00519     offsetX = 20;    offsetY = 100;
00520     for (int y = 0; y < 20; y++)
00521         for (int x = 0; x < 20; x++)
00522             hud->data[limitX.intForceLimit(x + offsetX) + hud->width * limitY.intForceLimit(y + offsetY)] = menu->data[number * 400 + x + 20 * y];
00523             
00524     // comb
00525     number = 28;
00526     offsetX = 40;    offsetY = 100;
00527     for (int y = 0; y < 20; y++)
00528         for (int x = 0; x < 20; x++)
00529             hud->data[limitX.intForceLimit(x + offsetX) + hud->width * limitY.intForceLimit(y + offsetY)] = menu->data[number * 400 + x + 20 * y];
00530             
00531     // dots
00532     number = 29;
00533     offsetX = 60;    offsetY = 100;
00534     for (int y = 0; y < 20; y++)
00535         for (int x = 0; x < 20; x++)
00536             hud->data[limitX.intForceLimit(x + offsetX) + hud->width * limitY.intForceLimit(y + offsetY)] = menu->data[number * 400 + x + 20 * y];
00537             
00538     // lines
00539     number = 30;
00540     offsetX = 90;    offsetY = 100;
00541     for (int y = 0; y < 20; y++)
00542         for (int x = 0; x < 20; x++)
00543             hud->data[limitX.intForceLimit(x + offsetX) + hud->width * limitY.intForceLimit(y + offsetY)] = menu->data[number * 400 + x + 20 * y];
00544             
00545     // rgbpoints
00546     number = 31;
00547     offsetX = 110;    offsetY = 100;
00548     for (int y = 0; y < 20; y++)
00549         for (int x = 0; x < 20; x++)
00550             hud->data[limitX.intForceLimit(x + offsetX) + hud->width * limitY.intForceLimit(y + offsetY)] = menu->data[number * 400 + x + 20 * y];
00551             
00552     // noise
00553     number = 32;
00554     offsetX = 130;    offsetY = 100;
00555     for (int y = 0; y < 20; y++)
00556         for (int x = 0; x < 20; x++)
00557             hud->data[limitX.intForceLimit(x + offsetX) + hud->width * limitY.intForceLimit(y + offsetY)] = menu->data[number * 400 + x + 20 * y];
00558 
00559 // zeile 6
00560     // blur
00561     number = 33;
00562     offsetX = 0;    offsetY = 120;
00563     for (int y = 0; y < 20; y++)
00564         for (int x = 0; x < 20; x++)
00565             hud->data[limitX.intForceLimit(x + offsetX) + hud->width * limitY.intForceLimit(y + offsetY)] = menu->data[number * 400 + x + 20 * y];
00566             
00567     // sharpen
00568     number = 34;
00569     offsetX = 20;    offsetY = 120;
00570     for (int y = 0; y < 20; y++)
00571         for (int x = 0; x < 20; x++)
00572             hud->data[limitX.intForceLimit(x + offsetX) + hud->width * limitY.intForceLimit(y + offsetY)] = menu->data[number * 400 + x + 20 * y];
00573             
00574     // edge
00575     number = 35;
00576     offsetX = 40;    offsetY = 120;
00577     for (int y = 0; y < 20; y++)
00578         for (int x = 0; x < 20; x++)
00579             hud->data[limitX.intForceLimit(x + offsetX) + hud->width * limitY.intForceLimit(y + offsetY)] = menu->data[number * 400 + x + 20 * y];
00580             
00581     // emboss
00582     number = 36;
00583     offsetX = 60;    offsetY = 120;
00584     for (int y = 0; y < 20; y++)
00585         for (int x = 0; x < 20; x++)
00586             hud->data[limitX.intForceLimit(x + offsetX) + hud->width * limitY.intForceLimit(y + offsetY)] = menu->data[number * 400 + x + 20 * y];
00587             
00588     // separate
00589     number = 37;
00590     offsetX = 80;    offsetY = 120;
00591     for (int y = 0; y < 20; y++)
00592         for (int x = 0; x < 20; x++)
00593             hud->data[limitX.intForceLimit(x + offsetX) + hud->width * limitY.intForceLimit(y + offsetY)] = menu->data[number * 400 + x + 20 * y];
00594             
00595     // halfblur
00596     number = 38;
00597     offsetX = 100;    offsetY = 120;
00598     for (int y = 0; y < 20; y++)
00599         for (int x = 0; x < 20; x++)
00600             hud->data[limitX.intForceLimit(x + offsetX) + hud->width * limitY.intForceLimit(y + offsetY)] = menu->data[number * 400 + x + 20 * y];
00601             
00602     // whiteblur
00603     number = 39;
00604     offsetX = 120;    offsetY = 120;
00605     for (int y = 0; y < 20; y++)
00606         for (int x = 0; x < 20; x++)
00607             hud->data[limitX.intForceLimit(x + offsetX) + hud->width * limitY.intForceLimit(y + offsetY)] = menu->data[number * 400 + x + 20 * y];
00608             
00609     // blackblur
00610     number = 40;
00611     offsetX = 140;    offsetY = 120;
00612     for (int y = 0; y < 20; y++)
00613         for (int x = 0; x < 20; x++)
00614             hud->data[limitX.intForceLimit(x + offsetX) + hud->width * limitY.intForceLimit(y + offsetY)] = menu->data[number * 400 + x + 20 * y];
00615 
00616 // zeile 7
00617     // chrome
00618     number = 41;
00619     offsetX = 0;    offsetY = 140;
00620     for (int y = 0; y < 20; y++)
00621         for (int x = 0; x < 20; x++)
00622             hud->data[limitX.intForceLimit(x + offsetX) + hud->width * limitY.intForceLimit(y + offsetY)] = menu->data[number * 400 + x + 20 * y];
00623             
00624     // bw
00625     number = 42;
00626     offsetX = 20;    offsetY = 140;
00627     for (int y = 0; y < 20; y++)
00628         for (int x = 0; x < 20; x++)
00629             hud->data[limitX.intForceLimit(x + offsetX) + hud->width * limitY.intForceLimit(y + offsetY)] = menu->data[number * 400 + x + 20 * y];
00630             
00631     // relief
00632     number = 43;
00633     offsetX = 40;    offsetY = 140;
00634     for (int y = 0; y < 20; y++)
00635         for (int x = 0; x < 20; x++)
00636             hud->data[limitX.intForceLimit(x + offsetX) + hud->width * limitY.intForceLimit(y + offsetY)] = menu->data[number * 400 + x + 20 * y];
00637             
00638     // cutout
00639     number = 44;
00640     offsetX = 60;    offsetY = 140;
00641     for (int y = 0; y < 20; y++)
00642         for (int x = 0; x < 20; x++)
00643             hud->data[limitX.intForceLimit(x + offsetX) + hud->width * limitY.intForceLimit(y + offsetY)] = menu->data[number * 400 + x + 20 * y];
00644             
00645     // brush
00646     number = 45;
00647     offsetX = 90;    offsetY = 140;
00648     for (int y = 0; y < 20; y++)
00649         for (int x = 0; x < 20; x++)
00650             hud->data[limitX.intForceLimit(x + offsetX) + hud->width * limitY.intForceLimit(y + offsetY)] = menu->data[number * 400 + x + 20 * y];
00651             
00652     // spatter
00653     number = 46;
00654     offsetX = 110;    offsetY = 140;
00655     for (int y = 0; y < 20; y++)
00656         for (int x = 0; x < 20; x++)
00657             hud->data[limitX.intForceLimit(x + offsetX) + hud->width * limitY.intForceLimit(y + offsetY)] = menu->data[number * 400 + x + 20 * y];
00658 
00659     // strokes
00660     number = 47;
00661     offsetX = 130;    offsetY = 140;
00662     for (int y = 0; y < 20; y++)
00663         for (int x = 0; x < 20; x++)
00664             hud->data[limitX.intForceLimit(x + offsetX) + hud->width * limitY.intForceLimit(y + offsetY)] = menu->data[number * 400 + x + 20 * y];
00665 
00666     // starlight
00667     number = 48;
00668     offsetX = 160;    offsetY = 140;
00669     for (int y = 0; y < 20; y++)
00670         for (int x = 0; x < 20; x++)
00671             hud->data[limitX.intForceLimit(x + offsetX) + hud->width * limitY.intForceLimit(y + offsetY)] = menu->data[number * 400 + x + 20 * y];
00672 
00673     // shine
00674     number = 49;
00675     offsetX = 180;    offsetY = 140;
00676     for (int y = 0; y < 20; y++)
00677         for (int x = 0; x < 20; x++)
00678             hud->data[limitX.intForceLimit(x + offsetX) + hud->width * limitY.intForceLimit(y + offsetY)] = menu->data[number * 400 + x + 20 * y];
00679 
00680 // modes
00681     // mode = 1
00682     if (numModes > 1)
00683     {
00684         number = 101;
00685         offsetX = 0;    offsetY = 180;
00686         for (int y = 0; y < 20; y++)
00687             for (int x = 0; x < 20; x++)
00688                 hud->data[limitX.intForceLimit(x + offsetX) + hud->width * limitY.intForceLimit(y + offsetY)] = menu->data[number * 400 + x + 20 * y];
00689     }
00690 
00691     // mode = 2
00692     if (numModes >= 2)
00693     {
00694         number = 102;
00695         offsetX = 20;    offsetY = 180;
00696         for (int y = 0; y < 20; y++)
00697             for (int x = 0; x < 20; x++)
00698                 hud->data[limitX.intForceLimit(x + offsetX) + hud->width * limitY.intForceLimit(y + offsetY)] = menu->data[number * 400 + x + 20 * y];
00699     }
00700 
00701     // mode = 3
00702     if (numModes >= 3)
00703     {
00704         number = 103;
00705         offsetX = 40;    offsetY = 180;
00706         for (int y = 0; y < 20; y++)
00707             for (int x = 0; x < 20; x++)
00708                 hud->data[limitX.intForceLimit(x + offsetX) + hud->width * limitY.intForceLimit(y + offsetY)] = menu->data[number * 400 + x + 20 * y];
00709     }
00710 
00711     // mode = 4
00712     if (numModes >= 4)
00713     {
00714         number = 104;
00715         offsetX = 60;    offsetY = 180;
00716         for (int y = 0; y < 20; y++)
00717             for (int x = 0; x < 20; x++)
00718                 hud->data[limitX.intForceLimit(x + offsetX) + hud->width * limitY.intForceLimit(y + offsetY)] = menu->data[number * 400 + x + 20 * y];
00719     }
00720 
00721     // mode = 5
00722     if (numModes >= 5)
00723     {
00724         number = 105;
00725         offsetX = 80;    offsetY = 180;
00726         for (int y = 0; y < 20; y++)
00727             for (int x = 0; x < 20; x++)
00728                 hud->data[limitX.intForceLimit(x + offsetX) + hud->width * limitY.intForceLimit(y + offsetY)] = menu->data[number * 400 + x + 20 * y];
00729     }
00730 
00731     // mode = 6
00732     if (numModes >= 6)
00733     {
00734         number = 106;
00735         offsetX = 100;    offsetY = 180;
00736         for (int y = 0; y < 20; y++)
00737             for (int x = 0; x < 20; x++)
00738                 hud->data[limitX.intForceLimit(x + offsetX) + hud->width * limitY.intForceLimit(y + offsetY)] = menu->data[number * 400 + x + 20 * y];
00739     }
00740 
00741     // mode = 7
00742     if (numModes >= 7)
00743     {
00744         number = 107;
00745         offsetX = 120;    offsetY = 180;
00746         for (int y = 0; y < 20; y++)
00747             for (int x = 0; x < 20; x++)
00748                 hud->data[limitX.intForceLimit(x + offsetX) + hud->width * limitY.intForceLimit(y + offsetY)] = menu->data[number * 400 + x + 20 * y];
00749     }
00750 
00751     // mode = 8
00752     if (numModes >= 8)
00753     {
00754         number = 108;
00755         offsetX = 140;    offsetY = 180;
00756         for (int y = 0; y < 20; y++)
00757             for (int x = 0; x < 20; x++)
00758                 hud->data[limitX.intForceLimit(x + offsetX) + hud->width * limitY.intForceLimit(y + offsetY)] = menu->data[number * 400 + x + 20 * y];
00759     }
00760     
00761 // regler
00762     // value 1
00763     if (limitValue1.low != limitValue1.high)
00764     {
00765         number = 109;
00766         offsetX = 0;    offsetY = 200;
00767         for (int y = 0; y < 20; y++)
00768             for (int x = 0; x < 20; x++)
00769                 hud->data[limitX.intForceLimit(x + offsetX) + hud->width * limitY.intForceLimit(y + offsetY)] = menu->data[number * 400 + x + 20 * y];
00770         number = 110;
00771         offsetX = 20;    offsetY = 200;
00772         for (int y = 0; y < 20; y++)
00773             for (int x = 0; x < 20; x++)
00774                 hud->data[limitX.intForceLimit(x + offsetX) + hud->width * limitY.intForceLimit(y + offsetY)] = menu->data[number * 400 + x + 20 * y];
00775         number = 110;
00776         offsetX = 40;    offsetY = 200;
00777         for (int y = 0; y < 20; y++)
00778             for (int x = 0; x < 20; x++)
00779                 hud->data[limitX.intForceLimit(x + offsetX) + hud->width * limitY.intForceLimit(y + offsetY)] = menu->data[number * 400 + x + 20 * y];
00780         number = 111;
00781         offsetX = 60;    offsetY = 200;
00782         for (int y = 0; y < 20; y++)
00783             for (int x = 0; x < 20; x++)
00784                 hud->data[limitX.intForceLimit(x + offsetX) + hud->width * limitY.intForceLimit(y + offsetY)] = menu->data[number * 400 + x + 20 * y];
00785 
00786         number = 112;
00787         offsetX = 0 + 7 + int((value1 - limitValue1.low) / (limitValue1.high - limitValue1.low) * 60);    offsetY = 200 + 3;
00788         for (int y = 0; y < 14; y++)
00789             for (int x = 0; x < 7; x++)
00790                 hud->data[limitX.intForceLimit(x + offsetX) + hud->width * limitY.intForceLimit(y + offsetY)] = menu->data[number * 400 + x + 20 * y];
00791     }
00792     
00793     // value 2
00794     if (limitValue2.low != limitValue2.high)
00795     {
00796         number = 109;
00797         offsetX = 80;    offsetY = 200;
00798         for (int y = 0; y < 20; y++)
00799             for (int x = 0; x < 20; x++)
00800                 hud->data[limitX.intForceLimit(x + offsetX) + hud->width * limitY.intForceLimit(y + offsetY)] = menu->data[number * 400 + x + 20 * y];
00801         number = 110;
00802         offsetX = 100;    offsetY = 200;
00803         for (int y = 0; y < 20; y++)
00804             for (int x = 0; x < 20; x++)
00805                 hud->data[limitX.intForceLimit(x + offsetX) + hud->width * limitY.intForceLimit(y + offsetY)] = menu->data[number * 400 + x + 20 * y];
00806         number = 110;
00807         offsetX = 120;    offsetY = 200;
00808         for (int y = 0; y < 20; y++)
00809             for (int x = 0; x < 20; x++)
00810                 hud->data[limitX.intForceLimit(x + offsetX) + hud->width * limitY.intForceLimit(y + offsetY)] = menu->data[number * 400 + x + 20 * y];
00811         number = 111;
00812         offsetX = 140;    offsetY = 200;
00813         for (int y = 0; y < 20; y++)
00814             for (int x = 0; x < 20; x++)
00815                 hud->data[limitX.intForceLimit(x + offsetX) + hud->width * limitY.intForceLimit(y + offsetY)] = menu->data[number * 400 + x + 20 * y];
00816 
00817         number = 112;
00818         offsetX = 80 + 7 + int((value2 - limitValue2.low) / (limitValue2.high - limitValue2.low) * 60);    offsetY = 200 + 3;
00819         for (int y = 0; y < 14; y++)
00820             for (int x = 0; x < 7; x++)
00821                 hud->data[limitX.intForceLimit(x + offsetX) + hud->width * limitY.intForceLimit(y + offsetY)] = menu->data[number * 400 + x + 20 * y];
00822     }              
00823             
00824     if (bColorMenu)
00825     {
00826         for (int y = 0; y < 50; y++)
00827         {
00828             for (int x = 100; x < 165; x++)
00829             {
00830                 if (x < img->width && y < img->height)
00831                 {
00832                     float S = (1.0*(50-y)/25);
00833                     float V = (1.0*(y)/25);
00834                     if (V > 1) { V = 1; }
00835                     if (S > 1) { S = 1; }
00836                     hud->data[x + img->width * y] = HSVtoRGB((Hsva){1.0*(x-100)/65*360, S, V, 255});
00837                 }
00838             }
00839         }
00840         for (int y = 0; y < 50; y++)
00841         {
00842             for (int x = 165; x < 180; x++)
00843             {
00844                 int brightness = myColor.r + myColor.g + myColor.b;
00845                 
00846                 int location = x + img->width * y;
00847                 hud->data[location].r = limitRGBA.intForceLimit(myColor.r + 1.0*(y-(1.0*brightness/(3*255)*50))/50*255);
00848                 hud->data[location].g = limitRGBA.intForceLimit(myColor.g + 1.0*(y-(1.0*brightness/(3*255)*50))/50*255);
00849                 hud->data[location].b = limitRGBA.intForceLimit(myColor.b + 1.0*(y-(1.0*brightness/(3*255)*50))/50*255);
00850                 hud->data[location].a = 255;
00851             }
00852         }
00853         for (int y = 30; y < 50; y++)
00854         {
00855             for (int x = 190; x < 210; x++)
00856             {
00857                 hud->data[x + img->width * y] = myColor;
00858             }
00859         }
00860     }
00861 }
00862 /*
00863 void effect::showBar()
00864 {
00865     for (int y = (img->height - 16); y < img->height; y++)
00866     {
00867         for (int x = (img->width - 106); x < img->width; x++)
00868         {
00869             if (y >= 0 && x >= 0)
00870             {
00871                 if ((img->height - y) < 4 || (img->height - y) > 13 || (img->width - x) < 4 || (img->width - x) > 103)
00872                     hud->data[x + img->width * y] = (Rgba) { 160, 160, 160, 255 };
00873                 else
00874                 {
00875                     if ((100-(img->height - x - 4)) <= progress)
00876                         hud->data[x + img->width * y] = (Rgba) { 0, 0, 255, 255 };
00877                     else
00878                         hud->data[x + img->width * y] = (Rgba) { 200, 200, 200, 255 };
00879                 }                    
00880 
00881             }
00882         }
00883     }
00884 }
00885 */
00886 bool effect::useMenu(bool firstClick)
00887 {
00888     if (firstClick)
00889     {
00890         // Zeile 1
00891         if (mouse.x >= 0 && mouse.x < (0 + 20) && mouse.y >= 0 && mouse.y < (0 + 20)) // save (0)
00892         {    imageRgbaWriteTIFF("out.tif", img); bMenu = !bMenu; return true;   }
00893         else if (mouse.x >= 20 && mouse.x < (20 + 20) && mouse.y >= 0 && mouse.y < (0 + 20)) // backwards (1)
00894         {    resetImage(); bMenu = !bMenu; return true; }
00895         else if (mouse.x > (img->width - 20) && mouse.x <= img->width && mouse.y >= 0 && mouse.y < (0 +20)) // close (2)
00896         {    exit(0); return true; }
00897         else if (mouse.x >= 50 && mouse.x < (50 + 20) && mouse.y >= 0 && mouse.y < (0 + 20)) // zoom in (7)
00898         {    fwkSetDisplayZoom(2 * fwkGetDisplayZoom()); return true;    }
00899         else if (mouse.x >= 70 && mouse.x < (70 + 20) && mouse.y >= 0 && mouse.y < (0 + 20)) // zoom out (8)
00900         {    fwkSetDisplayZoom(0.5 * fwkGetDisplayZoom()); return true; }
00901     
00902         // Zeile 2
00903         else if (mouse.x >= 0 && mouse.x < (0 + 20) && mouse.y >= 30 && mouse.y < (30 + 20)) // draw (3)
00904         {    changeEffect(3); return true; }
00905         else if (mouse.x >= 20 && mouse.x < (20 + 20) && mouse.y >= 30 && mouse.y < (30 + 20)) // selection (4)
00906         {    changeEffect(4); return true; }
00907         else if (mouse.x >= 40 && mouse.x < (40 + 20) && mouse.y >= 30 && mouse.y < (30 + 20)) // scroll (5)
00908         {    changeEffect(5); return true; }
00909         else if (mouse.x >= 60 && mouse.x < (60 + 20) && mouse.y >= 30 && mouse.y < (30 + 20)) // telescope (6)
00910         {    changeEffect(6); return true; }
00911             
00912         // Zeile 3
00913         else if (mouse.x >= 0 && mouse.x < (0 + 20) && mouse.y >= 60 && mouse.y < (60 + 20)) // brightness (9)
00914         {    changeEffect(9); return true; }
00915         else if (mouse.x >= 20 && mouse.x < (20 + 20) && mouse.y >= 60 && mouse.y < (60 + 20)) // contrast (10)
00916         {    changeEffect(10); return true; }
00917         else if (mouse.x >= 40 && mouse.x < (40 + 20) && mouse.y >= 60 && mouse.y < (60 + 20)) // saturation (11)
00918         {    changeEffect(11); return true; }
00919         else if (mouse.x >= 60 && mouse.x < (60 + 20) && mouse.y >= 60 && mouse.y < (60 + 20)) // hue (12)
00920         {    changeEffect(12); return true; }
00921         else if (mouse.x >= 80 && mouse.x < (80 + 20) && mouse.y >= 60 && mouse.y < (60 + 20)) // colorize (13)
00922         {    changeEffect(13); return true; }
00923         else if (mouse.x >= 100 && mouse.x < (100 + 20) && mouse.y >= 60 && mouse.y < (60 + 20)) // channel (14)
00924         {    changeEffect(14); return true; }
00925         else if (mouse.x >= 130 && mouse.x < (130 + 20) && mouse.y >= 60 && mouse.y < (60 + 20)) // gray (15)
00926         {    changeEffect(15); return true; }
00927         else if (mouse.x >= 150 && mouse.x < (150 + 20) && mouse.y >= 60 && mouse.y < (60 + 20)) // invert (16)
00928         {    changeEffect(16); return true; }
00929         else if (mouse.x >= 170 && mouse.x < (170 + 20) && mouse.y >= 60 && mouse.y < (60 + 20)) // posterize (17)
00930         {    changeEffect(17); return true; }
00931         else if (mouse.x >= 190 && mouse.x < (190 + 20) && mouse.y >= 60 && mouse.y < (60 + 20)) // solarize (18)
00932         {    changeEffect(18); return true; }
00933     
00934         // Zeile 4
00935         else if (mouse.x >= 0 && mouse.x < (0 + 20) && mouse.y >= 80 && mouse.y < (80 + 20)) // ripple (19)
00936         {    changeEffect(19); return true; }
00937         else if (mouse.x >= 20 && mouse.x < (20 + 20) && mouse.y >= 80 && mouse.y < (80 + 20)) // bulb (20)
00938         {    changeEffect(20); return true; }
00939         else if (mouse.x >= 40 && mouse.x < (40 + 20) && mouse.y >= 80 && mouse.y < (80 + 20)) // twirl (21)
00940         {    changeEffect(21); return true; }
00941         else if (mouse.x >= 60 && mouse.x < (60 + 20) && mouse.y >= 80 && mouse.y < (80 + 20)) // lens (22)
00942         {    changeEffect(22); return true; }
00943         else if (mouse.x >= 80 && mouse.x < (80 + 20) && mouse.y >= 80 && mouse.y < (80 + 20)) // wave (23)
00944         {    changeEffect(23); return true; }
00945         else if (mouse.x >= 110 && mouse.x < (110 + 20) && mouse.y >= 80 && mouse.y < (80 + 20)) // buttonize (24)
00946         {    changeEffect(24); return true; }
00947          else if (mouse.x >= 130 && mouse.x < (130 + 20) && mouse.y >= 80 && mouse.y < (80 + 20)) // glass (25)
00948         {    changeEffect(25); return true; }
00949        
00950         // Zeile 5
00951         else if (mouse.x >= 0 && mouse.x < (0 + 20) && mouse.y >= 100 && mouse.y < (100 + 20)) // mosaik (26)
00952         {    changeEffect(26); return true; }
00953         else if (mouse.x >= 20 && mouse.x < (20 + 20) && mouse.y >= 100 && mouse.y < (100 + 20)) // box (27)
00954         {    changeEffect(27); return true; }
00955         else if (mouse.x >= 40 && mouse.x < (40 + 20) && mouse.y >= 100 && mouse.y < (100 + 20)) // comb (28)
00956         {    changeEffect(28); return true; }
00957         else if (mouse.x >= 60 && mouse.x < (60 + 20) && mouse.y >= 100 && mouse.y < (100 + 20)) // dots (29)
00958         {    changeEffect(29); return true; }
00959         else if (mouse.x >= 90 && mouse.x < (90 + 20) && mouse.y >= 100 && mouse.y < (100 + 20)) // lines (30)
00960         {    changeEffect(30); return true; }
00961         else if (mouse.x >= 110 && mouse.x < (110 + 20) && mouse.y >= 100 && mouse.y < (100 + 20)) // rgbdots (31)
00962         {    changeEffect(31); return true; }
00963         else if (mouse.x >= 130 && mouse.x < (130 + 20) && mouse.y >= 100 && mouse.y < (100 + 20)) // noise (32)
00964         {    changeEffect(32); return true; }
00965 
00966         // Zeile 6
00967         else if (mouse.x >= 0 && mouse.x < (0 + 20) && mouse.y >= 120 && mouse.y < (120 + 20)) // blur (33)
00968         {    changeEffect(33); return true; }
00969         else if (mouse.x >= 20 && mouse.x < (20 + 20) && mouse.y >= 120 && mouse.y < (120 + 20)) // sharpen (34)
00970         {    changeEffect(34); return true; }
00971         else if (mouse.x >= 40 && mouse.x < (40 + 20) && mouse.y >= 120 && mouse.y < (120 + 20)) // edge (35)
00972         {    changeEffect(35); return true; }
00973         else if (mouse.x >= 60 && mouse.x < (60 + 20) && mouse.y >= 120 && mouse.y < (120 + 20)) // emboss (36)
00974         {    changeEffect(36); return true; }
00975         else if (mouse.x >= 80 && mouse.x < (80 + 20) && mouse.y >= 120 && mouse.y < (120 + 20)) // separate (37)
00976         {    changeEffect(37); return true; }
00977         else if (mouse.x >= 100 && mouse.x < (100 + 20) && mouse.y >= 120 && mouse.y < (120 + 20)) // halbblur (38)
00978         {    changeEffect(38); return true; }
00979         else if (mouse.x >= 120 && mouse.x < (120 + 20) && mouse.y >= 120 && mouse.y < (120 + 20)) // whiteblur (39)
00980         {    changeEffect(39); return true; }
00981         else if (mouse.x >= 140 && mouse.x < (140 + 20) && mouse.y >= 120 && mouse.y < (120 + 20)) // blackblur (40)
00982         {    changeEffect(40); return true; }
00983 
00984         // Zeile 7
00985         else if (mouse.x >= 0 && mouse.x < (0 + 20) && mouse.y >= 140 && mouse.y < (140 + 20)) // chrome (41)
00986         {    changeEffect(41); return true; }
00987         else if (mouse.x >= 20 && mouse.x < (20 + 20) && mouse.y >= 140 && mouse.y < (140 + 20)) // bw (42)
00988         {    changeEffect(42); return true; }
00989         else if (mouse.x >= 40 && mouse.x < (40 + 20) && mouse.y >= 140 && mouse.y < (140 + 20)) // relief (43)
00990         {    changeEffect(43); return true; }
00991         else if (mouse.x >= 60 && mouse.x < (60 + 20) && mouse.y >= 140 && mouse.y < (140 + 20)) // cutout (44)
00992         {    changeEffect(44); return true; }
00993         else if (mouse.x >= 90 && mouse.x < (90 + 20) && mouse.y >= 140 && mouse.y < (140 + 20)) // brush (45)
00994         {    changeEffect(45); return true; }
00995         else if (mouse.x >= 110 && mouse.x < (110 + 20) && mouse.y >= 140 && mouse.y < (140 + 20)) // spatter (46)
00996         {    changeEffect(46); return true; }
00997         else if (mouse.x >= 130 && mouse.x < (130 + 20) && mouse.y >= 140 && mouse.y < (140 + 20)) // strokes (47)
00998         {    changeEffect(47); return true; }
00999         else if (mouse.x >= 160 && mouse.x < (160 + 20) && mouse.y >= 140 && mouse.y < (140 + 20)) // starlight (48)
01000         {    changeEffect(48); return true; }
01001         else if (mouse.x >= 180 && mouse.x < (180 + 20) && mouse.y >= 140 && mouse.y < (140 + 20)) // shine (49)
01002         {    changeEffect(49); return true; }
01003 
01004         // Modes
01005         else if (mouse.x >= 0 && mouse.x < (0 + 20) && mouse.y >= 180 && mouse.y < (180 + 20) && numModes > 1) // change mode 1
01006         {    changeMode(1); bMenu = !bMenu; return true; }
01007         else if (mouse.x >= 20 && mouse.x < (20 + 20) && mouse.y >= 180 && mouse.y < (180 + 20) && numModes >= 2) // change mode 2
01008         {    changeMode(2); bMenu = !bMenu; return true; }
01009         else if (mouse.x >= 40 && mouse.x < (40 + 20) && mouse.y >= 180 && mouse.y < (180 + 20) && numModes >= 3) // change mode 3
01010         {    changeMode(3); bMenu = !bMenu; return true; }
01011         else if (mouse.x >= 60 && mouse.x < (60 + 20) && mouse.y >= 180 && mouse.y < (180 + 20) && numModes >= 4) // change mode 4
01012         {    changeMode(4); bMenu = !bMenu; return true; }
01013         else if (mouse.x >= 80 && mouse.x < (80 + 20) && mouse.y >= 180 && mouse.y < (180 + 20) && numModes >= 5) // change mode 5
01014         {    changeMode(5); bMenu = !bMenu; return true; }
01015         else if (mouse.x >= 100 && mouse.x < (100 + 20) && mouse.y >= 180 && mouse.y < (180 + 20) && numModes >= 6) // change mode 6
01016         {    changeMode(6); bMenu = !bMenu; return true; }
01017         else if (mouse.x >= 120 && mouse.x < (120 + 20) && mouse.y >= 180 && mouse.y < (180 + 20) && numModes >= 7) // change mode 7
01018         {    changeMode(7); bMenu = !bMenu; return true; }
01019         else if (mouse.x >= 140 && mouse.x < (140 + 20) && mouse.y >= 180 && mouse.y < (180 + 20) && numModes >= 8) // change mode 8
01020         {    changeMode(8); bMenu = !bMenu; return true; }
01021 
01022         // Regler
01023 //      else if (mouse.x >= (0 + 7 + int((value1 - limitValue1.low) / (limitValue1.high - limitValue1.low) * 60)) && mouse.x < ((0 + 7 + int((value1 - limitValue1.low) / (limitValue1.high - limitValue1.low) * 60)) + 7) && mouse.y >= (200 + 3) && mouse.y < ((200 + 3) + 14) && limitValue1.low != limitValue1.high) // value 1
01024         else if (mouse.x >= 2 && mouse.x < 78 && mouse.y >= (200 + 3) && mouse.y < ((200 + 3) + 14) && limitValue1.low != limitValue1.high) // value 1
01025         {    value1 = limitValue1.forceLimit(int(limitValue1.low + ((mouse.x - (10 + 0)) / 60.0 * (limitValue1.high - limitValue1.low)))); changeValue(0); return false; }
01026 //      else if (mouse.x >= (80 + 7 + int((value1 - limitValue1.low) / (limitValue1.high - limitValue1.low) * 60)) && mouse.x < ((80 + 7 + int((value1 - limitValue1.low) / (limitValue1.high - limitValue1.low) * 60)) + 7) && mouse.y >= (200 + 3) && mouse.y < ((200 + 3) + 14) && limitValue2.low != limitValue2.high) // value 1
01027         else if (mouse.x >= 82 && mouse.x < 158 && mouse.y >= (200 + 3) && mouse.y < ((200 + 3) + 14) && limitValue2.low != limitValue2.high) // value 1
01028         {    value2 = limitValue2.forceLimit(int(limitValue2.low + ((mouse.x - (10 + 80)) / 60.0 * (limitValue2.high - limitValue2.low)))); changeValue(0); return false; }
01029         
01030         // Color Menu
01031         else if (bColorMenu && mouse.x >= 100 && mouse.x < 180 && mouse.y >= 0 && mouse.y < 50)
01032         {   myColor = hud->data[mouse.x + img->width * mouse.y]; myColor.a = 255; this->colorChangeAction(); return false;  }
01033 
01034         else    
01035             return false;
01036             
01037         
01038     }
01039     else
01040     {
01041 // Regler
01042 //      if (mouse.x >= (0 + 7 + int((value1 - limitValue1.low) / (limitValue1.high - limitValue1.low) * 60)) && mouse.x < ((0 + 7 + int((value1 - limitValue1.low) / (limitValue1.high - limitValue1.low) * 60)) + 7) && mouse.y >= (200 + 3) && mouse.y < ((200 + 3) + 14) && limitValue1.low != limitValue1.high) // value 1
01043         if (mouse.x >= 7 && mouse.x < 73 && mouse.y >= (200 + 3) && mouse.y < ((200 + 3) + 14) && limitValue1.low != limitValue1.high) // value 1
01044         {    value1 = limitValue1.forceLimit(int(limitValue1.low + ((mouse.x - (10 + 0)) / 60.0 * (limitValue1.high - limitValue1.low)))); changeValue(1); return true; }
01045 //      else if (mouse.x >= (80 + 7 + int((value1 - limitValue1.low) / (limitValue1.high - limitValue1.low) * 60)) && mouse.x < ((80 + 7 + int((value1 - limitValue1.low) / (limitValue1.high - limitValue1.low) * 60)) + 7) && mouse.y >= (200 + 3) && mouse.y < ((200 + 3) + 14) && limitValue2.low != limitValue2.high) // value 1
01046         else if (mouse.x >= 87 && mouse.x < 153 && mouse.y >= (200 + 3) && mouse.y < ((200 + 3) + 14) && limitValue2.low != limitValue2.high) // value 1
01047         {    value2 = limitValue2.forceLimit(int(limitValue2.low + ((mouse.x - (10 + 80)) / 60.0 * (limitValue2.high - limitValue2.low)))); changeValue(1); return true; }
01048 // Color Menu
01049         else if (bColorMenu && mouse.x >= 100 && mouse.x < 180 && mouse.y >= 0 && mouse.y < 50)
01050         {   myColor = hud->data[mouse.x + img->width * mouse.y]; myColor.a = 255; this->colorChangeAction(); return true;  }
01051 
01052         else    
01053             return false;
01054     }
01055 }
01056 
01057 void effect::showHud()
01058 {
01059     if (bArea || bMenu)// || bProgressBar)
01060     {
01061         imageRgbaSet(hud, 0, 0, 0, 0);
01062         if (bArea)
01063             this->showArea();
01064         if (bMenu)
01065             this->showMenu();
01066 //        if (bProgressBar)
01067 //            this->showBar();
01068             
01069         for (int y = 0; y < img->height; y++)
01070         {
01071             for (int x = 0; x < img->width; x++)
01072             {
01073                 int location = x + img->width * y;
01074                 if (hud->data[location].a == 0)
01075                     hud->data[location] = img->data[location];
01076             }
01077         }
01078         display = hud;
01079         this->refreshImage();
01080     }
01081     else 
01082     {
01083         display = img;
01084         this->refreshImage();
01085     }
01086 }
01087 
01088 void effect::refreshImage()
01089 {
01090     fwkSetDisplayImage(display);
01091 //    fwkPostRedisplay();
01092 }
01093 
01094 
01096 // Color                                                                     //
01098 void color::LBAction()
01099 {
01100     if (LBpressed)
01101     {
01102         int location;
01103         for (int y = lowArea.y; y <= highArea.y; y++)
01104         {
01105             for (int x = lowArea.x; x <= highArea.x; x++)
01106             {
01107                 location = x + img->width * y;
01108                 this->action(location);
01109             }
01110         }
01111     }
01112 }
01113 
01114 void color::RBAction()
01115 {
01116     if (RBpressed)
01117         imageRgbaCopy(temp, img);
01118 }
01119 
01120 void color::action(int location)
01121 {
01122 }
01123 
01124 void color::changeValue(char _key)
01125 {
01126     if (_key == GLUT_KEY_UP)
01127         value1 += 5;
01128     else if (_key == GLUT_KEY_DOWN)
01129         value1 -= 5;
01130         
01131     value1 = limitValue1.intForceLimit(value1);
01132 
01133     if (_key)
01134     {
01135         if (!LBpressed)
01136         {
01137             LBpressed = true;
01138             this->LBAction();
01139             LBpressed = false;
01140         }
01141         else
01142             this->LBAction();
01143     }
01144 }
01145 
01147 // Geometric                                                                 //
01149 void geometric::idleAction()
01150 {
01151 }
01152 
01153 void geometric::RBAction()
01154 {
01155     if (RBpressed)
01156         imageRgbaCopy(temp, img);
01157 }
01158 
01159 void geometric::specialKey(int _key)
01160 {
01161     inAction = inActionState;
01162 
01163     if (_key <= numModes)
01164         this->changeMode(_key);
01165         
01166     if (_key == GLUT_KEY_LEFT || _key == GLUT_KEY_RIGHT || _key == GLUT_KEY_UP || _key == GLUT_KEY_DOWN)
01167         this->changeValue(_key);
01168         
01169     if (_key == GLUT_KEY_END)
01170     {
01171         interpolate = !interpolate;
01172         if (!LBpressed)
01173         {
01174             LBpressed = true;
01175             this->idleAction();
01176             LBpressed = false;
01177         }
01178         else
01179             this->idleAction();
01180     }
01181 }
01182 
01183 void geometric::changeValue(char _key)
01184 {
01185     if (_key == GLUT_KEY_UP)
01186         this->keyUP();
01187     else if (_key == GLUT_KEY_DOWN)
01188         this->keyDOWN();
01189     else if (_key == GLUT_KEY_LEFT)
01190         this->keyLEFT();
01191     else if (_key == GLUT_KEY_RIGHT)
01192         this->keyRIGHT();
01193         
01194     if (_key)
01195     {
01196         if (!LBpressed)
01197         {
01198             LBpressed = true;
01199             this->idleAction();
01200             LBpressed = false;
01201         }
01202         else
01203             this->idleAction();
01204     }
01205 }
01206 
01207 void geometric::keyRIGHT()
01208 {
01209 }
01210 
01211 void geometric::keyLEFT()
01212 {
01213 }
01214 
01215 void geometric::keyUP()
01216 {
01217 }
01218 
01219 void geometric::keyDOWN()
01220 {
01221 }
01222 
01224 // Distort                                                                   //
01226 void distort::LBAction()
01227 {
01228 }
01229 
01230 void distort::RBAction()
01231 {
01232     if (RBpressed)
01233         imageRgbaCopy(temp, img);
01234 }
01235 
01236 void distort::changeValue(char _key)
01237 {
01238     if (_key == GLUT_KEY_UP)
01239         value2 += 1;
01240     else if (_key == GLUT_KEY_DOWN)
01241         value2 -= 1;
01242     else if (_key == GLUT_KEY_RIGHT)
01243         value1 += 1;
01244     else if (_key == GLUT_KEY_LEFT)
01245         value1 -= 1;
01246         
01247     value1 = limitValue1.intForceLimit(value1);
01248     value2 = limitValue2.intForceLimit(value2);
01249 
01250     if (_key)
01251     {
01252         if (!LBpressed)
01253         {
01254             LBpressed = true;
01255             this->LBAction();
01256             LBpressed = false;
01257         }
01258         else
01259             this->LBAction();
01260     }
01261 }
01262 
01264 // Matrices                                                                   //
01266 void matrices::RBAction()
01267 {
01268     if (RBpressed)
01269         imageRgbaCopy(temp, img);
01270 }
01271 
01272 void matrices::LBAction()
01273 {
01274     if (LBpressed)
01275     {
01276         for (int y = lowArea.y; y <= highArea.y; y++)
01277         {
01278             for (int x = lowArea.x; x <= highArea.x; x++)
01279             {
01280                 this->matrixAction(x, y);
01281             }
01282         }
01283     }
01284 }
01285 
01286 void matrices::matrixAction(int _x, int _y)
01287 {
01288     img->data[_x + img->width * _y] = applyMatrix(temp, M[int(value1)], _x, _y, lowArea, highArea);
01289 }
01290 
01291 void matrices::changeValue(char _key)
01292 {
01293     if (_key == GLUT_KEY_UP)
01294         value1 += 1;
01295     else if (_key == GLUT_KEY_DOWN)
01296         value1 -= 1;
01297 
01298     if (_key == GLUT_KEY_LEFT)
01299         value2 -= 3;
01300     else if (_key == GLUT_KEY_RIGHT)
01301         value2 += 3;
01302 
01303     if (_key == 127)
01304     {
01305         strength -= 1;
01306         if (strength < 1)
01307             strength = 1;
01308     }
01309     else if (_key == GLUT_KEY_PAGE_DOWN)
01310     {
01311         strength += 1;
01312         if (strength > 30)
01313             strength = 30;
01314     }
01315 
01316     value1 = limitValue1.intForceLimit(value1);
01317     value2 = limitValue2.intForceLimit(value2);
01318     
01319     if (_key)
01320     {
01321         if (!LBpressed)
01322         {
01323             LBpressed = true;
01324             this->LBAction();
01325             LBpressed = false;
01326         }
01327         else
01328             this->LBAction();
01329     }
01330 }
01331 
01332 void matrices::key(unsigned char _key)
01333 {
01334     inAction = inActionState;
01335 
01336     if (_key == ' ')
01337         bMenu = !bMenu;
01338     if (_key == 127)
01339         this->changeValue(_key);
01340 }
01341 
01342 void matrices::specialKey(int _key)
01343 {
01344     inAction = inActionState;
01345 
01346     if (_key <= numModes)
01347         this->changeMode(_key);
01348         
01349     if (_key == GLUT_KEY_LEFT || _key == GLUT_KEY_RIGHT || _key == GLUT_KEY_UP || _key == GLUT_KEY_DOWN || _key == GLUT_KEY_PAGE_DOWN)
01350         this->changeValue(_key);
01351 }
01352 
01354 // Artistic                                                                  //
01356 void artistic::RBAction()
01357 {
01358     if (RBpressed)
01359         imageRgbaCopy(temp, img);
01360 }
01361 
01362 void artistic::changeValue(char _key)
01363 {
01364     if (_key == GLUT_KEY_UP)
01365         value1 += 1;
01366     else if (_key == GLUT_KEY_DOWN)
01367         value1 -= 1;
01368     else if (_key == GLUT_KEY_RIGHT)
01369         value2 += 1;
01370     else if (_key == GLUT_KEY_LEFT)
01371         value2 -= 1;
01372         
01373     value1 = limitValue1.intForceLimit(value1);
01374     value2 = limitValue2.intForceLimit(value2);
01375 
01376     if (_key == 127)
01377     {
01378         strength -= 1;
01379         if (strength < 1)
01380             strength = 1;
01381     }
01382     else if (_key == GLUT_KEY_PAGE_DOWN)
01383     {
01384         strength += 1;
01385         if (strength > 30)
01386             strength = 30;
01387     }
01388 
01389     if (_key)
01390     {
01391         if (!LBpressed)
01392         {
01393             LBpressed = true;
01394             this->LBAction();
01395             LBpressed = false;
01396         }
01397         else
01398             this->LBAction();
01399     }
01400 }
01401 
01402 void artistic::key(unsigned char _key)
01403 {
01404     inAction = inActionState;
01405 
01406     if (_key == ' ')
01407         bMenu = !bMenu;
01408     if (_key == 127)
01409         this->changeValue(_key);
01410 }
01411 
01412 void artistic::specialKey(int _key)
01413 {
01414     inAction = inActionState;
01415 
01416     if (_key <= numModes)
01417         this->changeMode(_key);
01418 
01419     if (_key == GLUT_KEY_LEFT || _key == GLUT_KEY_RIGHT || _key == GLUT_KEY_UP || _key == GLUT_KEY_DOWN || _key == GLUT_KEY_PAGE_DOWN)
01420         this->changeValue(_key);
01421 }

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