Rev 8158 | Rev 8163 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 8158 | Rev 8162 | ||
---|---|---|---|
Line 15... | Line 15... | ||
15 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
15 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
16 | */ |
16 | */ |
17 | #include "flydraw.h" |
17 | #include "flydraw.h" |
18 | #include <errno.h> |
18 | #include <errno.h> |
19 | /* bug in gdImageFillToBorder */ |
19 | /* bug in gdImageFillToBorder */ |
20 | void gdImageFillToBorder1 (gdImagePtr im, int x, int y, int border, int color) |
- | |
21 | { |
- | |
22 | if(x>=im->sx) x=im->sx-1; if(x<0) x=0; |
- | |
23 | if(y>=im->sy) y=im->sy-1; if(y<0) y=0; |
- | |
24 | gdImageFillToBorder(im,x,y,border,color); |
- | |
25 | } |
- | |
26 | 20 | ||
27 | void |
21 | void patchgdImageFillToBorder (gdImagePtr im, int x, int y, int border, int color) |
28 | { |
22 | { |
29 | if(x>=im->sx || x<0 || y>=im->sy || y<0) return; |
23 | if(x>=im->sx || x<0 || y>=im->sy || y<0) return; |
30 | gdImageFillToBorder(im,x,y,border,color); |
24 | gdImageFillToBorder(im,x,y,border,color); |
31 | } |
25 | } |
32 | 26 | ||
33 | void |
27 | void patchgdImageFill (gdImagePtr im, int x, int y, int color) |
34 | { |
28 | { |
35 | if(x>=im->sx || x<0 || y>=im->sy || y<0) return; |
29 | if(x>=im->sx || x<0 || y>=im->sy || y<0) return; |
36 | gdImageFill(im,x,y,color); |
30 | gdImageFill(im,x,y,color); |
37 | } |
31 | } |
38 | 32 | ||
Line 383... | Line 377... | ||
383 | scale(pm->pd,pm->p,1); |
377 | scale(pm->pd,pm->p,1); |
384 | pm->p[2]=rint(pm->pd[2]*xscale); pm->p[3]=rint(pm->pd[3]*yscale); |
378 | pm->p[2]=rint(pm->pd[2]*xscale); pm->p[3]=rint(pm->pd[3]*yscale); |
385 | if(pm->fill) { |
379 | if(pm->fill) { |
386 | gdImageArc(image,pm->p[0],pm->p[1],pm->p[2],pm->p[3],0,360, |
380 | gdImageArc(image,pm->p[0],pm->p[1],pm->p[2],pm->p[3],0,360, |
387 | color_bounder); |
381 | color_bounder); |
388 |
|
382 | patchgdImageFillToBorder(image,pm->p[0],pm->p[1], |
389 | color_bounder,pm->color[0]); |
383 | color_bounder,pm->color[0]); |
390 | } |
384 | } |
391 | gdImageArc(image,pm->p[0],pm->p[1],pm->p[2],pm->p[3],0,360,pm->color[0]); |
385 | gdImageArc(image,pm->p[0],pm->p[1],pm->p[2],pm->p[3],0,360,pm->color[0]); |
392 | if(vimg_enable) vimg_ellipse(scale_buf[0],scale_buf[1],0.5*pm->pd[2],0.5*pm->pd[3]); |
386 | if(vimg_enable) vimg_ellipse(scale_buf[0],scale_buf[1],0.5*pm->pd[2],0.5*pm->pd[3]); |
393 | } |
387 | } |
Line 398... | Line 392... | ||
398 | scale(pm->pd,pm->p,1); |
392 | scale(pm->pd,pm->p,1); |
399 | pm->p[2]=rint(pm->pd[2]); pm->p[3]=rint(pm->pd[2]); |
393 | pm->p[2]=rint(pm->pd[2]); pm->p[3]=rint(pm->pd[2]); |
400 | if(pm->fill) { |
394 | if(pm->fill) { |
401 | gdImageArc(image,pm->p[0],pm->p[1],pm->p[2],pm->p[3],0,360, |
395 | gdImageArc(image,pm->p[0],pm->p[1],pm->p[2],pm->p[3],0,360, |
402 | color_bounder); |
396 | color_bounder); |
403 |
|
397 | patchgdImageFillToBorder(image,pm->p[0],pm->p[1], |
404 | color_bounder,pm->color[0]); |
398 | color_bounder,pm->color[0]); |
405 | } |
399 | } |
406 | gdImageArc(image,pm->p[0],pm->p[1],pm->p[2],pm->p[3],0,360,pm->color[0]); |
400 | gdImageArc(image,pm->p[0],pm->p[1],pm->p[2],pm->p[3],0,360,pm->color[0]); |
407 | } |
401 | } |
408 | 402 | ||
409 | /* flood fill */ |
403 | /* flood fill */ |
410 | void obj_fill(objparm *pm) |
404 | void obj_fill(objparm *pm) |
411 | { |
405 | { |
412 | scale(pm->pd,pm->p,1); |
406 | scale(pm->pd,pm->p,1); |
413 |
|
407 | patchgdImageFill(image,pm->p[0],pm->p[1],pm->color[0]); |
414 | } |
408 | } |
415 | 409 | ||
416 | /* flood fill to border*/ |
410 | /* flood fill to border*/ |
417 | void obj_fillb(objparm *pm) |
411 | void obj_fillb(objparm *pm) |
418 | { |
412 | { |
419 | scale(pm->pd,pm->p,1); |
413 | scale(pm->pd,pm->p,1); |
420 |
|
414 | patchgdImageFillToBorder(image,pm->p[0],pm->p[1],pm->color[0],pm->color[1]); |
421 | } |
415 | } |
422 | 416 | ||
423 | gdImagePtr himg; |
417 | gdImagePtr himg; |
424 | 418 | ||
425 | int makehatchimage(int x, int y, int px, int py, int col) |
419 | int makehatchimage(int x, int y, int px, int py, int col) |
Line 475... | Line 469... | ||
475 | } |
469 | } |
476 | case 2: gdImageLine(himg,0,ay/2,ax-1,ay/2,c); break; |
470 | case 2: gdImageLine(himg,0,ay/2,ax-1,ay/2,c); break; |
477 | case 3: gdImageLine(himg,ax/2,0,ax/2,ay-1,c); break; |
471 | case 3: gdImageLine(himg,ax/2,0,ax/2,ay-1,c); break; |
478 | } |
472 | } |
479 | gdImageSetTile(image,himg); |
473 | gdImageSetTile(image,himg); |
480 |
|
474 | patchgdImageFill(image,pm->p[0],pm->p[1],gdTiled); |
481 | gdImageDestroy(himg); |
475 | gdImageDestroy(himg); |
482 | if(tiled) gdImageSetTile(image,tileimg); |
476 | if(tiled) gdImageSetTile(image,tileimg); |
483 | } |
477 | } |
484 | 478 | ||
485 | /* flood fill with grid */ |
479 | /* flood fill with grid */ |
Line 490... | Line 484... | ||
490 | nx=pm->pd[2]; ny=pm->pd[3]; nx=abs(nx); ny=abs(ny); |
484 | nx=pm->pd[2]; ny=pm->pd[3]; nx=abs(nx); ny=abs(ny); |
491 | if(nx==0 && ny==0) {error("bad grid size"); return;} |
485 | if(nx==0 && ny==0) {error("bad grid size"); return;} |
492 | c=makehatchimage(nx,ny,pm->p[0],pm->p[1],pm->color[0]); |
486 | c=makehatchimage(nx,ny,pm->p[0],pm->p[1],pm->color[0]); |
493 | gdImageLine(himg,0,ny/2,nx-1,ny/2,c); gdImageLine(himg,nx/2,0,nx/2,ny-1,c); |
487 | gdImageLine(himg,0,ny/2,nx-1,ny/2,c); gdImageLine(himg,nx/2,0,nx/2,ny-1,c); |
494 | gdImageSetTile(image,himg); |
488 | gdImageSetTile(image,himg); |
495 |
|
489 | patchgdImageFill(image,pm->p[0],pm->p[1],gdTiled); |
496 | gdImageDestroy(himg); |
490 | gdImageDestroy(himg); |
497 | if(tiled) gdImageSetTile(image,tileimg); |
491 | if(tiled) gdImageSetTile(image,tileimg); |
498 | } |
492 | } |
499 | 493 | ||
500 | /* flood fill with double hatching */ |
494 | /* flood fill with double hatching */ |
Line 505... | Line 499... | ||
505 | nx=pm->pd[2]; ny=pm->pd[3]; nx=abs(nx); ny=abs(ny); |
499 | nx=pm->pd[2]; ny=pm->pd[3]; nx=abs(nx); ny=abs(ny); |
506 | if(nx==0 && ny==0) {error("bad grid size"); return;} |
500 | if(nx==0 && ny==0) {error("bad grid size"); return;} |
507 | c=makehatchimage(nx,ny,pm->p[0],pm->p[1],pm->color[0]); |
501 | c=makehatchimage(nx,ny,pm->p[0],pm->p[1],pm->color[0]); |
508 | gdImageLine(himg,0,0,nx-1,ny-1,c); gdImageLine(himg,0,ny-1,nx-1,0,c); |
502 | gdImageLine(himg,0,0,nx-1,ny-1,c); gdImageLine(himg,0,ny-1,nx-1,0,c); |
509 | gdImageSetTile(image,himg); |
503 | gdImageSetTile(image,himg); |
510 |
|
504 | patchgdImageFill(image,pm->p[0],pm->p[1],gdTiled); |
511 | gdImageDestroy(himg); |
505 | gdImageDestroy(himg); |
512 | if(tiled) gdImageSetTile(image,tileimg); |
506 | if(tiled) gdImageSetTile(image,tileimg); |
513 | } |
507 | } |
514 | 508 | ||
515 | /* flood fill with double hatching */ |
509 | /* flood fill with double hatching */ |
Line 520... | Line 514... | ||
520 | nx=pm->pd[2]; ny=pm->pd[3]; nx=abs(nx); ny=abs(ny); |
514 | nx=pm->pd[2]; ny=pm->pd[3]; nx=abs(nx); ny=abs(ny); |
521 | if(nx==0 && ny==0) {error("bad grid size"); return;} |
515 | if(nx==0 && ny==0) {error("bad grid size"); return;} |
522 | c=makehatchimage(nx,ny,pm->p[0],pm->p[1],pm->color[0]); |
516 | c=makehatchimage(nx,ny,pm->p[0],pm->p[1],pm->color[0]); |
523 | gdImageSetPixel(himg,nx/2,ny/2,c); |
517 | gdImageSetPixel(himg,nx/2,ny/2,c); |
524 | gdImageSetTile(image,himg); |
518 | gdImageSetTile(image,himg); |
525 |
|
519 | patchgdImageFill(image,pm->p[0],pm->p[1],gdTiled); |
526 | gdImageDestroy(himg); |
520 | gdImageDestroy(himg); |
527 | if(tiled) gdImageSetTile(image,tileimg); |
521 | if(tiled) gdImageSetTile(image,tileimg); |
528 | } |
522 | } |
529 | 523 | ||
530 | struct { |
524 | struct { |