Subversion Repositories wimsdev

Rev

Rev 8102 | Rev 8158 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 8102 Rev 8156
Line 17... Line 17...
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)
20
void gdImageFillToBorder1 (gdImagePtr im, int x, int y, int border, int color)
21
{
21
{
22
   if(x>=image->sx) x=image->sx-1; if(x<0) x=0;
22
   if(x>=im->sx) x=im->sx-1; if(x<0) x=0;
23
   if(y>=image->sy) y=image->sy-1; if(y<0) y=0;
23
   if(y>=im->sy) y=im->sy-1; if(y<0) y=0;
24
   gdImageFillToBorder(im,x,y,border,color);
24
   gdImageFillToBorder(im,x,y,border,color);
25
}
25
}
26
 
26
 
27
void gdImageFillToBorder2 (gdImagePtr im, int x, int y, int border, int color)
27
void gdImageFillToBorder2 (gdImagePtr im, int x, int y, int border, int color)
28
{
28
{
29
   if(x>=image->sx || x<0 || y>=image->sy || y<0) return;
29
   if(x>=im->sx || x<0 || y>=im->sy || y<0) return;
30
   gdImageFillToBorder(im,x,y,border,color);
30
   gdImageFillToBorder(im,x,y,border,color);
-
 
31
}
-
 
32
 
-
 
33
void gdImageFill2 (gdImagePtr im, int x, int y, int color)
-
 
34
{
-
 
35
   if(x>=im->sx || x<0 || y>=im->sy || y<0) return;
-
 
36
   gdImageFill(im,x,y,color);
31
}
37
}
32
 
38
 
33
 
39
 
34
/* File opening: with security */
40
/* File opening: with security */
35
FILE *open4read(char *n)
41
FILE *open4read(char *n)
Line 401... Line 407...
401
 
407
 
402
/* flood fill */
408
/* flood fill */
403
void obj_fill(objparm *pm)
409
void obj_fill(objparm *pm)
404
{
410
{
405
    scale(pm->pd,pm->p,1);
411
    scale(pm->pd,pm->p,1);
406
    gdImageFill(image,pm->p[0],pm->p[1],pm->color[0]);
412
    gdImageFill2(image,pm->p[0],pm->p[1],pm->color[0]);
407
}
413
}
408
 
414
 
409
/* flood fill to border*/
415
/* flood fill to border*/
410
void obj_fillb(objparm *pm)
416
void obj_fillb(objparm *pm)
411
{
417
{
Line 468... Line 474...
468
      }
474
      }
469
      case 2: gdImageLine(himg,0,ay/2,ax-1,ay/2,c); break;
475
      case 2: gdImageLine(himg,0,ay/2,ax-1,ay/2,c); break;
470
      case 3: gdImageLine(himg,ax/2,0,ax/2,ay-1,c); break;
476
      case 3: gdImageLine(himg,ax/2,0,ax/2,ay-1,c); break;
471
    }
477
    }
472
    gdImageSetTile(image,himg);
478
    gdImageSetTile(image,himg);
473
    gdImageFill(image,pm->p[0],pm->p[1],gdTiled);
479
    gdImageFill2(image,pm->p[0],pm->p[1],gdTiled);
474
    gdImageDestroy(himg);
480
    gdImageDestroy(himg);
475
    if(tiled) gdImageSetTile(image,tileimg);
481
    if(tiled) gdImageSetTile(image,tileimg);
476
}
482
}
477
 
483
 
478
/* flood fill with grid */
484
/* flood fill with grid */
Line 483... Line 489...
483
    nx=pm->pd[2]; ny=pm->pd[3]; nx=abs(nx); ny=abs(ny);
489
    nx=pm->pd[2]; ny=pm->pd[3]; nx=abs(nx); ny=abs(ny);
484
    if(nx==0 && ny==0) {error("bad grid size"); return;}
490
    if(nx==0 && ny==0) {error("bad grid size"); return;}
485
    c=makehatchimage(nx,ny,pm->p[0],pm->p[1],pm->color[0]);
491
    c=makehatchimage(nx,ny,pm->p[0],pm->p[1],pm->color[0]);
486
    gdImageLine(himg,0,ny/2,nx-1,ny/2,c); gdImageLine(himg,nx/2,0,nx/2,ny-1,c);
492
    gdImageLine(himg,0,ny/2,nx-1,ny/2,c); gdImageLine(himg,nx/2,0,nx/2,ny-1,c);
487
    gdImageSetTile(image,himg);
493
    gdImageSetTile(image,himg);
488
    gdImageFill(image,pm->p[0],pm->p[1],gdTiled);
494
    gdImageFill2(image,pm->p[0],pm->p[1],gdTiled);
489
    gdImageDestroy(himg);
495
    gdImageDestroy(himg);
490
    if(tiled) gdImageSetTile(image,tileimg);
496
    if(tiled) gdImageSetTile(image,tileimg);
491
}
497
}
492
 
498
 
493
/* flood fill with double hatching */
499
/* flood fill with double hatching */
Line 498... Line 504...
498
    nx=pm->pd[2]; ny=pm->pd[3]; nx=abs(nx); ny=abs(ny);
504
    nx=pm->pd[2]; ny=pm->pd[3]; nx=abs(nx); ny=abs(ny);
499
    if(nx==0 && ny==0) {error("bad grid size"); return;}
505
    if(nx==0 && ny==0) {error("bad grid size"); return;}
500
    c=makehatchimage(nx,ny,pm->p[0],pm->p[1],pm->color[0]);
506
    c=makehatchimage(nx,ny,pm->p[0],pm->p[1],pm->color[0]);
501
    gdImageLine(himg,0,0,nx-1,ny-1,c); gdImageLine(himg,0,ny-1,nx-1,0,c);
507
    gdImageLine(himg,0,0,nx-1,ny-1,c); gdImageLine(himg,0,ny-1,nx-1,0,c);
502
    gdImageSetTile(image,himg);
508
    gdImageSetTile(image,himg);
503
    gdImageFill(image,pm->p[0],pm->p[1],gdTiled);
509
    gdImageFill2(image,pm->p[0],pm->p[1],gdTiled);
504
    gdImageDestroy(himg);
510
    gdImageDestroy(himg);
505
    if(tiled) gdImageSetTile(image,tileimg);
511
    if(tiled) gdImageSetTile(image,tileimg);
506
}
512
}
507
 
513
 
508
/* flood fill with double hatching */
514
/* flood fill with double hatching */
Line 513... Line 519...
513
    nx=pm->pd[2]; ny=pm->pd[3]; nx=abs(nx); ny=abs(ny);
519
    nx=pm->pd[2]; ny=pm->pd[3]; nx=abs(nx); ny=abs(ny);
514
    if(nx==0 && ny==0) {error("bad grid size"); return;}
520
    if(nx==0 && ny==0) {error("bad grid size"); return;}
515
    c=makehatchimage(nx,ny,pm->p[0],pm->p[1],pm->color[0]);
521
    c=makehatchimage(nx,ny,pm->p[0],pm->p[1],pm->color[0]);
516
    gdImageSetPixel(himg,nx/2,ny/2,c);
522
    gdImageSetPixel(himg,nx/2,ny/2,c);
517
    gdImageSetTile(image,himg);
523
    gdImageSetTile(image,himg);
518
    gdImageFill(image,pm->p[0],pm->p[1],gdTiled);
524
    gdImageFill2(image,pm->p[0],pm->p[1],gdTiled);
519
    gdImageDestroy(himg);
525
    gdImageDestroy(himg);
520
    if(tiled) gdImageSetTile(image,tileimg);
526
    if(tiled) gdImageSetTile(image,tileimg);
521
}
527
}
522
 
528
 
523
struct {
529
struct {