00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #include "GreyLab.h"
00032
00033
00034 #include "aaLine.h"
00035
00036
00037 #ifdef RGB
00038 #undef RGB
00039 #endif
00040 #define RGB(idx, r, g, b) \
00041 target[0+3*(idx)] = r; target[1+3*(idx)] = g; target[2+3*(idx)] = b;
00042 #define REDVAL(idx) target[0+3*(idx)]
00043 #define GREENVAL(idx) target[1+3*(idx)]
00044 #define BLUEVAL(idx) target[2+3*(idx)]
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060 void GreyLabWindow::renderString(FXString text, unsigned char *target,
00061 int totalW, int totalH, int sx, int sy, DrawPaletteDialog::primative::justification just, FXColor fg, FXColor bg)
00062 {
00063 int j, k;
00064 FXColor *strdata = NULL;
00065 const int fh = graphfont.fontheight;
00066 int w = graphfont.getStringDimensions(text);
00067 strdata = graphfont.drawAAString(text, w);
00068 int xo = 0;
00069 int yo = 0;
00070 switch (just)
00071 {
00072 case DrawPaletteDialog::primative::TL:
00073 yo = fh;
00074 break;
00075 case DrawPaletteDialog::primative::TR:
00076 {
00077 yo = fh;
00078 xo = w;
00079 }
00080 break;
00081 case DrawPaletteDialog::primative::BR:
00082 xo = w;
00083 break;
00084 case DrawPaletteDialog::primative::C:
00085 {
00086 yo = fh/2;
00087 xo = w/2;
00088 }
00089 break;
00090 default:
00091 break;
00092 }
00093 float a;
00094 unsigned char tgt[3];
00095 for (j = 0; j < w; ++j)
00096 for (k = 0; k < fh; ++k)
00097 if ((sx+j-xo >= 0) && (sx+j-xo < totalW) && (sy+k-yo >= 0) && (sy+k-yo < totalH))
00098 {
00099
00100
00101
00102
00103
00104
00105
00106 a = ((float)FXALPHAVAL(fg)/255.0)*(float)(1.0-(FXREDVAL(strdata[j+k*w])/255.0));
00107 tgt[0] = target[0+3*(sx+j-xo+(sy+k-yo)*totalW)];
00108 tgt[1] = target[1+3*(sx+j-xo+(sy+k-yo)*totalW)];
00109 tgt[2] = target[2+3*(sx+j-xo+(sy+k-yo)*totalW)];
00110 RGB(sx+j-xo+(sy+k-yo)*totalW, FXREDVAL(fg)*a+(1.0-a)*tgt[0], FXGREENVAL(fg)*a+(1.0-a)*tgt[1], FXBLUEVAL(fg)*a+(1.0-a)*tgt[2])
00111 }
00112 delete[] strdata;
00113 }
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138 void GreyLabWindow::renderObjects(DrawPaletteDialog *palette, unsigned char *target,
00139 int totalW, int totalH, int leftl, int bottoml, int xPx, int yPx,
00140 float xstart, float xend, float ystart, float yend,
00141 float lz, float hz, FXColor lc, FXColor hc, FXColor *colours, float gamma)
00142 {
00143 const int fh = graphfont.fontheight;
00144 int i, j, k;
00145 DrawPaletteDialog::primative *p;
00146 for (i = 0; i < palette->nPrimatives; ++i)
00147 {
00148 p = &palette->primatives[i];
00149 int sx, ex, sy, ey;
00150 switch (p->posmode)
00151 {
00152 case DrawPaletteDialog::primative::AXISABS:
00153 {
00154 sx = leftl+(int)(xPx*((p->position[0]-xstart)/(xend-xstart)));
00155 sy = bottoml+(int)(yPx*((p->position[1]-ystart)/(yend-ystart)));
00156 }
00157 break;
00158 case DrawPaletteDialog::primative::IMAGEFRAC:
00159 {
00160 sx = (int)(totalW*p->position[0]);
00161 sy = (int)(totalH*p->position[1]);
00162 }
00163 break;
00164 case DrawPaletteDialog::primative::IMAGEABS:
00165 {
00166 sx = (int)p->position[0];
00167 sy = (int)p->position[1];
00168 }
00169 break;
00170 case DrawPaletteDialog::primative::AXISFRAC:
00171 {
00172 sx = leftl+(int)(xPx*p->position[0]);
00173 sy = bottoml+(int)(yPx*p->position[1]);
00174 }
00175 break;
00176 case DrawPaletteDialog::primative::BORDERFRAC:
00177 {
00178 if (p->position[0] < 1.0)
00179 sx = (int)(leftl*p->position[0]);
00180 else if (p->position[0] < 2.0)
00181 sx = (int)(leftl+xPx*(p->position[0]-1.0));
00182 else
00183 sx = (int)(leftl+xPx+(totalW-xPx-leftl)*(p->position[0]-2.0));
00184 if (p->position[1] < 1.0)
00185 sy = (int)(bottoml*p->position[1]);
00186 else if (p->position[1] < 2.0)
00187 sy = (int)(bottoml+yPx*(p->position[1]-1.0));
00188 else
00189 sy = (int)(bottoml+yPx+(totalH-yPx-bottoml)*(p->position[1]-2.0));
00190 }
00191 break;
00192 default:
00193 break;
00194 }
00195 switch (p->dimmode)
00196 {
00197 case DrawPaletteDialog::primative::AXISABS:
00198 {
00199 ex = leftl+(int)(xPx*((p->dimensions[0]-xstart)/(xend-xstart)));
00200 ey = bottoml+(int)(yPx*((p->dimensions[1]-ystart)/(yend-ystart)));
00201 }
00202 break;
00203 case DrawPaletteDialog::primative::IMAGEFRAC:
00204 {
00205 ex = (int)(totalW*p->dimensions[0]);
00206 ey = (int)(totalH*p->dimensions[1]);
00207 }
00208 break;
00209 case DrawPaletteDialog::primative::IMAGEABS:
00210 {
00211 ex = (int)p->dimensions[0];
00212 ey = (int)p->dimensions[1];
00213 }
00214 break;
00215 case DrawPaletteDialog::primative::AXISFRAC:
00216 {
00217 ex = leftl+(int)(xPx*p->dimensions[0]);
00218 ey = bottoml+(int)(yPx*p->dimensions[1]);
00219 }
00220 break;
00221 case DrawPaletteDialog::primative::BORDERFRAC:
00222 {
00223 if (p->dimensions[0] < 1.0)
00224 ex = (int)(leftl*p->dimensions[0]);
00225 else if (p->dimensions[0] < 2.0)
00226 ex = (int)(leftl+xPx*(p->dimensions[0]-1.0));
00227 else
00228 ex = (int)(leftl+xPx+(totalW-xPx-leftl)*(p->dimensions[0]-2.0));
00229 if (p->dimensions[1] < 1.0)
00230 ey = (int)(bottoml*p->dimensions[1]);
00231 else if (p->dimensions[1] < 2.0)
00232 ey = (int)(bottoml+yPx*(p->dimensions[1]-1.0));
00233 else
00234 ey = (int)(bottoml+yPx+(totalH-yPx-bottoml)*(p->dimensions[1]-2.0));
00235 }
00236 break;
00237 default:
00238 break;
00239 }
00240 if (p->type == DrawPaletteDialog::primative::RECT)
00241 {
00242 if (p->startendgrad[0] == true)
00243 {
00244 DrawPaletteDialog::primative::justification just;
00245 if ((sx <= ex) && (sy <= ey)) just = DrawPaletteDialog::primative::TR;
00246 if ((sx <= ex) && (sy > ey)) just = DrawPaletteDialog::primative::BR;
00247 if ((sx > ex) && (sy <= ey)) just = DrawPaletteDialog::primative::TL;
00248 if ((sx > ex) && (sy > ey)) just = DrawPaletteDialog::primative::BL;
00249 renderString("("+FXStringVal(p->position[0])+", "+FXStringVal(p->position[1])+")", target, totalW, totalH, sx, sy, just, p->fg, p->bg);
00250 }
00251 if (p->startendgrad[1] == true)
00252 {
00253 DrawPaletteDialog::primative::justification just;
00254 if ((sx <= ex) && (sy <= ey)) just = DrawPaletteDialog::primative::BL;
00255 if ((sx <= ex) && (sy > ey)) just = DrawPaletteDialog::primative::TL;
00256 if ((sx > ex) && (sy <= ey)) just = DrawPaletteDialog::primative::BR;
00257 if ((sx > ex) && (sy > ey)) just = DrawPaletteDialog::primative::TR;
00258 renderString("("+FXStringVal(p->dimensions[0])+", "+FXStringVal(p->dimensions[1])+")", target, totalW, totalH, ex, ey, just, p->fg, p->bg);
00259 }
00260 if ((p->startendgrad[2] == true) && (p->startendgrad[3] == true))
00261 {
00262 renderString(FXStringVal((p->dimensions[1]-p->position[1])/(p->dimensions[0]-p->position[0])), target, totalW, totalH, (sx+ex)/2, (sy+ey)/2-fh/2, DrawPaletteDialog::primative::C, p->fg, p->bg);
00263 renderString("["+FXStringVal(p->dimensions[0]-p->position[0])+","+FXStringVal(p->dimensions[1]-p->position[1])+"]", target, totalW, totalH, (sx+ex)/2, (sy+ey)/2+fh/2, DrawPaletteDialog::primative::C, p->fg, p->bg);
00264 }
00265 else if (p->startendgrad[2] == true)
00266 renderString(FXStringVal((p->dimensions[1]-p->position[1])/(p->dimensions[0]-p->position[0])), target, totalW, totalH, (sx+ex)/2, (sy+ey)/2, DrawPaletteDialog::primative::C, p->fg, p->bg);
00267 else if (p->startendgrad[3] == true)
00268 renderString("["+FXStringVal(p->dimensions[0]-p->position[0])+","+FXStringVal(p->dimensions[1]-p->position[1])+"]", target, totalW, totalH, (sx+ex)/2, (sy+ey)/2, DrawPaletteDialog::primative::C, p->fg, p->bg);
00269
00270 float a = (float)FXALPHAVAL(p->bg)/255.0;
00271 int dx = 1;
00272 if (ex < sx) dx = -1;
00273 int dy = 1;
00274 if (ey < sy) dy = -1;
00275 for (j = sx; j != ex; j += dx)
00276 for (k = sy; k != ey; k += dy)
00277 if ((j >= 0) && (j < totalW) && (k >= 0) && (k < totalH))
00278 {
00279 RGB(j+k*totalW, FXREDVAL(p->bg)*a+(1.0-a)*REDVAL(j+k*totalW),
00280 FXGREENVAL(p->bg)*a+(1.0-a)*GREENVAL(j+k*totalW),
00281 FXBLUEVAL(p->bg)*a+(1.0-a)*BLUEVAL(j+k*totalW));
00282 }
00283 a = (float)FXALPHAVAL(p->fg)/255.0;
00284 for (j = sx-dx*p->stroke; j != ex+dx*p->stroke; j += dx)
00285 {
00286 for (k = sy-dy*p->stroke; k != sy; k += dy)
00287 if ((j >= 0) && (j < totalW) && (k >= 0) && (k < totalH))
00288 {
00289 RGB(j+k*totalW, FXREDVAL(p->fg)*a+(1.0-a)*REDVAL(j+k*totalW),
00290 FXGREENVAL(p->fg)*a+(1.0-a)*GREENVAL(j+k*totalW),
00291 FXBLUEVAL(p->fg)*a+(1.0-a)*BLUEVAL(j+k*totalW));
00292 }
00293 for (k = ey; k != ey+dy*p->stroke; k += dy)
00294 if ((j >= 0) && (j < totalW) && (k >= 0) && (k < totalH))
00295 {
00296 RGB(j+k*totalW, FXREDVAL(p->fg)*a+(1.0-a)*REDVAL(j+k*totalW),
00297 FXGREENVAL(p->fg)*a+(1.0-a)*GREENVAL(j+k*totalW),
00298 FXBLUEVAL(p->fg)*a+(1.0-a)*BLUEVAL(j+k*totalW));
00299 }
00300 }
00301 for (k = sy; k != ey; k += dy)
00302 {
00303 for (j = sx-dx*p->stroke; j != sx; j += dx)
00304 if ((j >= 0) && (j < totalW) && (k >= 0) && (k < totalH))
00305 {
00306 RGB(j+k*totalW, FXREDVAL(p->fg)*a+(1.0-a)*REDVAL(j+k*totalW),
00307 FXGREENVAL(p->fg)*a+(1.0-a)*GREENVAL(j+k*totalW),
00308 FXBLUEVAL(p->fg)*a+(1.0-a)*BLUEVAL(j+k*totalW));
00309 }
00310 for (j = ex; j != ex+dx*p->stroke; j += dx)
00311 if ((j >= 0) && (j < totalW) && (k >= 0) && (k < totalH))
00312 {
00313 RGB(j+k*totalW, FXREDVAL(p->fg)*a+(1.0-a)*REDVAL(j+k*totalW),
00314 FXGREENVAL(p->fg)*a+(1.0-a)*GREENVAL(j+k*totalW),
00315 FXBLUEVAL(p->fg)*a+(1.0-a)*BLUEVAL(j+k*totalW));
00316 }
00317 }
00318 }
00319 else if (p->type == DrawPaletteDialog::primative::LINE)
00320 {
00321 if (p->startendgrad[0] == true)
00322 {
00323 DrawPaletteDialog::primative::justification just;
00324 if ((sx <= ex) && (sy <= ey)) just = DrawPaletteDialog::primative::TR;
00325 if ((sx <= ex) && (sy > ey)) just = DrawPaletteDialog::primative::BR;
00326 if ((sx > ex) && (sy <= ey)) just = DrawPaletteDialog::primative::TL;
00327 if ((sx > ex) && (sy > ey)) just = DrawPaletteDialog::primative::BL;
00328 renderString("("+FXStringVal(p->position[0])+", "+FXStringVal(p->position[1])+")", target, totalW, totalH, sx, sy, just, p->fg, p->bg);
00329 }
00330 if (p->startendgrad[1] == true)
00331 {
00332 DrawPaletteDialog::primative::justification just;
00333 if ((sx <= ex) && (sy <= ey)) just = DrawPaletteDialog::primative::BL;
00334 if ((sx <= ex) && (sy > ey)) just = DrawPaletteDialog::primative::TL;
00335 if ((sx > ex) && (sy <= ey)) just = DrawPaletteDialog::primative::BR;
00336 if ((sx > ex) && (sy > ey)) just = DrawPaletteDialog::primative::TR;
00337 renderString("("+FXStringVal(p->dimensions[0])+", "+FXStringVal(p->dimensions[1])+")", target, totalW, totalH, ex, ey, just, p->fg, p->bg);
00338 }
00339 if (p->startendgrad[2] == true)
00340 {
00341 DrawPaletteDialog::primative::justification just;
00342 if (((ex-sx) >= 0.0) && ((ey-sy) >= 0.0)) just = DrawPaletteDialog::primative::TL;
00343 if (((ex-sx) >= 0.0) && ((ey-sy) < 0.0)) just = DrawPaletteDialog::primative::BL;
00344 if (((ex-sx) < 0.0) && ((ey-sy) >= 0.0)) just = DrawPaletteDialog::primative::TR;
00345 if (((ex-sx) < 0.0) && ((ey-sy) < 0.0)) just = DrawPaletteDialog::primative::BR;
00346 renderString(FXStringVal((p->dimensions[1]-p->position[1])/(p->dimensions[0]-p->position[0])), target, totalW, totalH, (sx+ex)/2, (sy+ey)/2, just, p->fg, p->bg);
00347 }
00348 if (p->startendgrad[3] == true)
00349 {
00350 DrawPaletteDialog::primative::justification just;
00351 if (((ex-sx) >= 0.0) && ((ey-sy) >= 0.0)) just = DrawPaletteDialog::primative::BR;
00352 if (((ex-sx) >= 0.0) && ((ey-sy) < 0.0)) just = DrawPaletteDialog::primative::TR;
00353 if (((ex-sx) < 0.0) && ((ey-sy) >= 0.0)) just = DrawPaletteDialog::primative::BL;
00354 if (((ex-sx) < 0.0) && ((ey-sy) < 0.0)) just = DrawPaletteDialog::primative::TL;
00355 renderString("["+FXStringVal(p->dimensions[0]-p->position[0])+","+FXStringVal(p->dimensions[1]-p->position[1])+"]", target, totalW, totalH, (sx+ex)/2, (sy+ey)/2, just, p->fg, p->bg);
00356 }
00357 int usx = sx;
00358 int uex = ex;
00359 int usy = sy;
00360 int uey = ey;
00361 if (sx > ex)
00362 {
00363 int temp = sx;
00364 sx = ex;
00365 ex = temp;
00366 temp = sy;
00367 sy = ey;
00368 ey = temp;
00369 }
00370 aacolstrokeline(target, totalW, sx, ex, sy, ey, p->fg, p->stroke, totalW, totalH);
00371 if (p->arrow[0] == true)
00372 {
00373 float l = sqrt((uex-usx)*(uex-usx)+(uey-usy)*(uey-usy));
00374 float aex = usx+(uex-usx)*p->arrowsize[0]/l+(uey-usy)*p->arrowsize[1]/l;
00375 float aey = usy+(uey-usy)*p->arrowsize[0]/l-(uex-usx)*p->arrowsize[1]/l;
00376 float x1, x2, y1, y2;
00377 if (usx <= aex) { x1 = usx; x2 = aex; y1 = usy; y2 = aey; }
00378 else { x1 = aex; x2 = usx; y1 = aey; y2 = usy; }
00379 aacolstrokeline(target, totalW, (int)x1, (int)x2, y1, y2, p->fg, p->stroke, totalW, totalH);
00380 aex = usx+(uex-usx)*p->arrowsize[0]/l-(uey-usy)*p->arrowsize[1]/l;
00381 aey = usy+(uey-usy)*p->arrowsize[0]/l+(uex-usx)*p->arrowsize[1]/l;
00382 if (usx <= aex) { x1 = usx; x2 = aex; y1 = usy; y2 = aey; }
00383 else { x1 = aex; x2 = usx; y1 = aey; y2 = usy; }
00384 aacolstrokeline(target, totalW, (int)x1, (int)x2, y1, y2, p->fg, p->stroke, totalW, totalH);
00385 }
00386 if (p->arrow[1] == true)
00387 {
00388 float l = sqrt((uex-usx)*(uex-usx)+(uey-usy)*(uey-usy));
00389 float aex = uex-(uex-usx)*p->arrowsize[0]/l+(uey-usy)*p->arrowsize[1]/l;
00390 float aey = uey-(uey-usy)*p->arrowsize[0]/l-(uex-usx)*p->arrowsize[1]/l;
00391 float x1, x2, y1, y2;
00392 if (uex <= aex) { x1 = uex; x2 = aex; y1 = uey; y2 = aey; }
00393 else { x1 = aex; x2 = uex; y1 = aey; y2 = uey; }
00394 aacolstrokeline(target, totalW, (int)x1, (int)x2, y1, y2, p->fg, p->stroke, totalW, totalH);
00395 aex = uex-(uex-usx)*p->arrowsize[0]/l-(uey-usy)*p->arrowsize[1]/l;
00396 aey = uey-(uey-usy)*p->arrowsize[0]/l+(uex-usx)*p->arrowsize[1]/l;
00397 if (uex <= aex) { x1 = uex; x2 = aex; y1 = uey; y2 = aey; }
00398 else { x1 = aex; x2 = uex; y1 = aey; y2 = uey; }
00399 aacolstrokeline(target, totalW, (int)x1, (int)x2, y1, y2, p->fg, p->stroke, totalW, totalH);
00400 }
00401 }
00402 else if (p->type == DrawPaletteDialog::primative::TEXT)
00403 {
00404
00405
00406 renderString(translateString(p->text->text()), target, totalW, totalH, sx, sy, p->justify, p->fg, p->bg);
00407 }
00408 else if (p->type == DrawPaletteDialog::primative::ELLIPSE)
00409 {
00410 if (p->startendgrad[0] == true)
00411 {
00412 DrawPaletteDialog::primative::justification just;
00413 if ((sx <= ex) && (sy <= ey)) just = DrawPaletteDialog::primative::TR;
00414 if ((sx <= ex) && (sy > ey)) just = DrawPaletteDialog::primative::BR;
00415 if ((sx > ex) && (sy <= ey)) just = DrawPaletteDialog::primative::TL;
00416 if ((sx > ex) && (sy > ey)) just = DrawPaletteDialog::primative::BL;
00417 renderString("("+FXStringVal(p->position[0])+", "+FXStringVal(p->position[1])+")", target, totalW, totalH, sx, sy, just, p->fg, p->bg);
00418 }
00419 if (p->startendgrad[1] == true)
00420 {
00421 DrawPaletteDialog::primative::justification just;
00422 if ((sx <= ex) && (sy <= ey)) just = DrawPaletteDialog::primative::BL;
00423 if ((sx <= ex) && (sy > ey)) just = DrawPaletteDialog::primative::TL;
00424 if ((sx > ex) && (sy <= ey)) just = DrawPaletteDialog::primative::BR;
00425 if ((sx > ex) && (sy > ey)) just = DrawPaletteDialog::primative::TR;
00426 renderString("("+FXStringVal(p->dimensions[0])+", "+FXStringVal(p->dimensions[1])+")", target, totalW, totalH, ex, ey, just, p->fg, p->bg);
00427 }
00428 if ((p->startendgrad[2] == true) && (p->startendgrad[3] == true))
00429 {
00430 renderString(FXStringVal((p->dimensions[1]-p->position[1])/(p->dimensions[0]-p->position[0])), target, totalW, totalH, (sx+ex)/2, (sy+ey)/2-fh/2, DrawPaletteDialog::primative::C, p->fg, p->bg);
00431 renderString("["+FXStringVal(p->dimensions[0]-p->position[0])+","+FXStringVal(p->dimensions[1]-p->position[1])+"]", target, totalW, totalH, (sx+ex)/2, (sy+ey)/2+fh/2, DrawPaletteDialog::primative::C, p->fg, p->bg);
00432 }
00433 else if (p->startendgrad[2] == true)
00434 renderString(FXStringVal((p->dimensions[1]-p->position[1])/(p->dimensions[0]-p->position[0])), target, totalW, totalH, (sx+ex)/2, (sy+ey)/2, DrawPaletteDialog::primative::C, p->fg, p->bg);
00435 else if (p->startendgrad[3] == true)
00436 renderString("["+FXStringVal(p->dimensions[0]-p->position[0])+","+FXStringVal(p->dimensions[1]-p->position[1])+"]", target, totalW, totalH, (sx+ex)/2, (sy+ey)/2, DrawPaletteDialog::primative::C, p->fg, p->bg);
00437
00438 float a = (float)FXALPHAVAL(p->bg)/255.0;
00439 int dx = 1;
00440 if (ex < sx) dx = -1;
00441 int dy = 1;
00442 if (ey < sy) dy = -1;
00443 for (j = -abs(ex-sx); j <= abs(ex-sx); ++j)
00444 for (k = -abs(ey-sy); k <= abs(ey-sy); ++k)
00445 if ((j+sx >= 0) && (j+sx < totalW) && (k+sy >= 0) && (k+sy < totalH))
00446 if ((((float)j/(float)(ex-sx))*((float)j/(float)(ex-sx))+
00447 ((float)k/(float)(ey-sy))*((float)k/(float)(ey-sy))) <= 1.0)
00448 {
00449 unsigned char tgt[3] = { target[0+3*(sx+j+(k+sy)*totalW)], target[1+3*(sx+j+(k+sy)*totalW)], target[2+3*(sx+j+(k+sy)*totalW)] };
00450 RGB(j+sx+(k+sy)*totalW, FXREDVAL(p->bg)*a+(1.0-a)*tgt[0],
00451 FXGREENVAL(p->bg)*a+(1.0-a)*tgt[1],
00452 FXBLUEVAL(p->bg)*a+(1.0-a)*tgt[2]);
00453 }
00454 a = (float)FXALPHAVAL(p->fg)/255.0;
00455 for (j = -abs(ex-sx)-p->stroke; j <= abs(ex-sx)+p->stroke; ++j)
00456 for (k = -abs(ey-sy)-p->stroke; k <= abs(ey-sy)+p->stroke; ++k)
00457 {
00458 float xx = (float)(ex-sx);
00459 float yy = (float)(ey-sy);
00460 float dxx = (float)(p->stroke+abs(ex-sx));
00461 float dyy = (float)(p->stroke+abs(ey-sy));
00462 if (((((float)j/xx)*((float)j/xx)+
00463 ((float)k/yy)*((float)k/yy)) > 1.0) &&
00464 ((((float)j/dxx)*((float)j/dxx)+
00465 ((float)k/dyy)*((float)k/dyy)) <= 1.0))
00466 if ((j+sx >= 0) && (j+sx < totalW) && (k+sy >= 0) && (k+sy < totalH))
00467 {
00468 unsigned char tgt[3] = { target[0+3*(sx+j+(k+sy)*totalW)], target[1+3*(sx+j+(k+sy)*totalW)], target[2+3*(sx+j+(k+sy)*totalW)] };
00469 RGB(j+sx+(k+sy)*totalW, FXREDVAL(p->fg)*a+(1.0-a)*tgt[0],
00470 FXGREENVAL(p->fg)*a+(1.0-a)*tgt[1],
00471 FXBLUEVAL(p->fg)*a+(1.0-a)*tgt[2]);
00472 }
00473 }
00474 }
00475 else if (p->type == DrawPaletteDialog::primative::IMAGE)
00476 {
00477 if (p->startendgrad[0] == true)
00478 {
00479 DrawPaletteDialog::primative::justification just;
00480 if ((sx <= ex) && (sy <= ey)) just = DrawPaletteDialog::primative::TR;
00481 if ((sx <= ex) && (sy > ey)) just = DrawPaletteDialog::primative::BR;
00482 if ((sx > ex) && (sy <= ey)) just = DrawPaletteDialog::primative::TL;
00483 if ((sx > ex) && (sy > ey)) just = DrawPaletteDialog::primative::BL;
00484 renderString("("+FXStringVal(p->position[0])+", "+FXStringVal(p->position[1])+")", target, totalW, totalH, sx, sy, just, p->fg, p->bg);
00485 }
00486 if (p->startendgrad[1] == true)
00487 {
00488 DrawPaletteDialog::primative::justification just;
00489 if ((sx <= ex) && (sy <= ey)) just = DrawPaletteDialog::primative::BL;
00490 if ((sx <= ex) && (sy > ey)) just = DrawPaletteDialog::primative::TL;
00491 if ((sx > ex) && (sy <= ey)) just = DrawPaletteDialog::primative::BR;
00492 if ((sx > ex) && (sy > ey)) just = DrawPaletteDialog::primative::TR;
00493 renderString("("+FXStringVal(p->dimensions[0])+", "+FXStringVal(p->dimensions[1])+")", target, totalW, totalH, ex, ey, just, p->fg, p->bg);
00494 }
00495 if ((p->startendgrad[2] == true) && (p->startendgrad[3] == true))
00496 {
00497 renderString(FXStringVal((p->dimensions[1]-p->position[1])/(p->dimensions[0]-p->position[0])), target, totalW, totalH, (sx+ex)/2, (sy+ey)/2-fh/2, DrawPaletteDialog::primative::C, p->fg, p->bg);
00498 renderString("["+FXStringVal(p->dimensions[0]-p->position[0])+","+FXStringVal(p->dimensions[1]-p->position[1])+"]", target, totalW, totalH, (sx+ex)/2, (sy+ey)/2+fh/2, DrawPaletteDialog::primative::C, p->fg, p->bg);
00499 }
00500 else if (p->startendgrad[2] == true)
00501 renderString(FXStringVal((p->dimensions[1]-p->position[1])/(p->dimensions[0]-p->position[0])), target, totalW, totalH, (sx+ex)/2, (sy+ey)/2, DrawPaletteDialog::primative::C, p->fg, p->bg);
00502 else if (p->startendgrad[3] == true)
00503 renderString("["+FXStringVal(p->dimensions[0]-p->position[0])+","+FXStringVal(p->dimensions[1]-p->position[1])+"]", target, totalW, totalH, (sx+ex)/2, (sy+ey)/2, DrawPaletteDialog::primative::C, p->fg, p->bg);
00504
00505 if (p->validimage == true)
00506 {
00507 ilBindImage(p->imageid);
00508 int xRes = ilGetInteger(IL_IMAGE_WIDTH);
00509 int yRes = ilGetInteger(IL_IMAGE_HEIGHT);
00510 float *tempdata = new float[xRes*yRes*4];
00511 ilCopyPixels(0, 0, 0, xRes, yRes, 1, IL_RGBA, IL_FLOAT, tempdata);
00512 if (sx > ex) { int temp = sx; sx = ex; ex = temp; }
00513 if (sy > ey) { int temp = sy; sy = ey; ey = temp; }
00514 float *rgba, a;
00515 for (j = 0; j < (ex-sx); ++j)
00516 for (k = 0; k < (ey-sy); ++k)
00517 if ((sx+j >= 0) && (sx+j < totalW) && (sy+k >= 0) && (sy+k < totalH))
00518 {
00519 rgba = &tempdata[4*((int)(xRes*((float)j/(float)(ex-sx)))+xRes*(int)(yRes*((float)k/(float)(ey-sy))))];
00520 a = rgba[3];
00521 unsigned char tgt[3] = { target[0+3*(sx+j+(k+sy)*totalW)], target[1+3*(sx+j+(k+sy)*totalW)], target[2+3*(sx+j+(k+sy)*totalW)] };
00522 RGB(j+sx+(k+sy)*totalW, 255.0*rgba[0]*a+(1.0-a)*tgt[0],
00523 255.0*rgba[1]*a+(1.0-a)*tgt[1],
00524 255.0*rgba[2]*a+(1.0-a)*tgt[2]);
00525 }
00526 delete[] tempdata;
00527 }
00528 }
00529 else if (p->type == DrawPaletteDialog::primative::FUNCTION)
00530 {
00531 if (p->startendgrad[0] == true)
00532 {
00533 DrawPaletteDialog::primative::justification just;
00534 if ((sx <= ex) && (sy <= ey)) just = DrawPaletteDialog::primative::TR;
00535 if ((sx <= ex) && (sy > ey)) just = DrawPaletteDialog::primative::BR;
00536 if ((sx > ex) && (sy <= ey)) just = DrawPaletteDialog::primative::TL;
00537 if ((sx > ex) && (sy > ey)) just = DrawPaletteDialog::primative::BL;
00538 renderString("("+FXStringVal(p->position[0])+", "+FXStringVal(p->position[1])+")", target, totalW, totalH, sx, sy, just, p->fg, p->bg);
00539 }
00540 if (p->startendgrad[1] == true)
00541 {
00542 DrawPaletteDialog::primative::justification just;
00543 if ((sx <= ex) && (sy <= ey)) just = DrawPaletteDialog::primative::BL;
00544 if ((sx <= ex) && (sy > ey)) just = DrawPaletteDialog::primative::TL;
00545 if ((sx > ex) && (sy <= ey)) just = DrawPaletteDialog::primative::BR;
00546 if ((sx > ex) && (sy > ey)) just = DrawPaletteDialog::primative::TR;
00547 renderString("("+FXStringVal(p->dimensions[0])+", "+FXStringVal(p->dimensions[1])+")", target, totalW, totalH, ex, ey, just, p->fg, p->bg);
00548 }
00549 if ((p->startendgrad[2] == true) && (p->startendgrad[3] == true))
00550 {
00551 renderString(FXStringVal((p->dimensions[1]-p->position[1])/(p->dimensions[0]-p->position[0])), target, totalW, totalH, (sx+ex)/2, (sy+ey)/2-fh/2, DrawPaletteDialog::primative::C, p->fg, p->bg);
00552 renderString("["+FXStringVal(p->dimensions[0]-p->position[0])+","+FXStringVal(p->dimensions[1]-p->position[1])+"]", target, totalW, totalH, (sx+ex)/2, (sy+ey)/2+fh/2, DrawPaletteDialog::primative::C, p->fg, p->bg);
00553 }
00554 else if (p->startendgrad[2] == true)
00