Subversion Repositories wimsdev

Rev

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

Rev 8195 Rev 8414
Line 308... Line 308...
308
      gdImageLine(image,pm->p[0],pm->p[1],pm->p[i],pm->p[i+1],pm->color[0]);
308
      gdImageLine(image,pm->p[0],pm->p[1],pm->p[i],pm->p[i+1],pm->color[0]);
309
      if(vimg_enable) vimg_line(scale_buf[0],scale_buf[1],
309
      if(vimg_enable) vimg_line(scale_buf[0],scale_buf[1],
310
                          scale_buf[i],scale_buf[i+1]);
310
                          scale_buf[i],scale_buf[i+1]);
311
    }
311
    }
312
}
312
}
-
 
313
/* crosshair */
-
 
314
void obj_crosshair(objparm *pm)
-
 
315
{
-
 
316
    scale(pm->pd,pm->p,2);
-
 
317
    gdImageLine(image,pm->p[0]+width2,pm->p[1]+width2,pm->p[0]-width2,pm->p[1]-width2,pm->color[0]);
-
 
318
    gdImageLine(image,pm->p[0]-width2,pm->p[1]+width2,pm->p[0]+width2,pm->p[1]-width2,pm->color[0]);
-
 
319
}
-
 
320
/* crosshairs */
313
 
321
 
-
 
322
void obj_crosshairs(objparm *pm)
-
 
323
{
-
 
324
    int i, n;
-
 
325
    n=(pm->pcnt)/2;
-
 
326
    scale(pm->pd,pm->p,n);
-
 
327
    for(i=0;i<2*n;i+=2) {
-
 
328
      gdImageLine(image,pm->p[i]+width2,pm->p[i+1]+width2,pm->p[i]-width2,pm->p[i+1]-width2,pm->color[0]);
-
 
329
      gdImageLine(image,pm->p[i]-width2,pm->p[i+1]+width2,pm->p[i]+width2,pm->p[i+1]-width2,pm->color[0]);
-
 
330
   }
-
 
331
}
-
 
332
 
-
 
333
 
314
/* segments */
334
/* segments */
315
void obj_lines(objparm *pm)
335
void obj_lines(objparm *pm)
316
{
336
{
317
    int i, n;
337
    int i, n;
318
    n=(pm->pcnt)/2;
338
    n=(pm->pcnt)/2;
319
    scale(pm->pd,pm->p,n);
339
    scale(pm->pd,pm->p,n);
320
    for(i=2;i<2*n;i+=2)
340
    for(i=2;i<2*n;i+=2)
Line 357... Line 377...
357
    for(i1=0;i1<n1;i1++) {
377
    for(i1=0;i1<n1;i1++) {
358
      xi1=rint(i1*xv1)+pm->p[0]; yi1=rint(i1*yv1)+pm->p[1];
378
      xi1=rint(i1*xv1)+pm->p[0]; yi1=rint(i1*yv1)+pm->p[1];
359
      for(i2=0;i2<n2;i2++) {
379
      for(i2=0;i2<n2;i2++) {
360
          xi2=i2*xv2+xi1;yi2=i2*yv2+yi1;
380
          xi2=i2*xv2+xi1;yi2=i2*yv2+yi1;
361
          gdImageSetPixel(image,xi2,yi2,pm->color[0]);
381
          gdImageSetPixel(image,xi2,yi2,pm->color[0]);
362
      }
382
      }
363
    }
383
    }
364
}
384
}
365
 
385
 
366
/* arc */
386
/* arc */
367
void obj_arc(objparm *pm)
387
void obj_arc(objparm *pm)
368
{
388
{
369
    scale(pm->pd,pm->p,1);
389
    scale(pm->pd,pm->p,1);
370
    pm->p[2]=rint(pm->pd[2]*xscale); pm->p[3]=rint(pm->pd[3]*yscale);
390
    pm->p[2]=rint(pm->pd[2]*xscale); pm->p[3]=rint(pm->pd[3]*yscale);
371
    gdImageArc(image,pm->p[0],pm->p[1],pm->p[2],pm->p[3],
391
    gdImageArc(image,pm->p[0],pm->p[1],pm->p[2],pm->p[3],
372
             pm->pd[4],pm->pd[5],pm->color[0]);
392
             pm->pd[4],pm->pd[5],pm->color[0]);
373
    if(vimg_enable) vimg_arc(scale_buf[0],scale_buf[1],
393
    if(vimg_enable) vimg_arc(scale_buf[0],scale_buf[1],
374
                       0.5*pm->pd[2],0.5*pm->pd[3],pm->pd[4],pm->pd[5]);
394
                       0.5*pm->pd[2],0.5*pm->pd[3],pm->pd[4],pm->pd[5]);
375
}
395
}
376
 
396
 
377
/* Ellipse: centre 0,1, width 2, hight 3, color 4,5,6 */
397
/* Ellipse: centre 0,1, width 2, hight 3, color 4,5,6 */
378
void obj_ellipse(objparm *pm)
398
void obj_ellipse(objparm *pm)
379
{
399
{
380
    scale(pm->pd,pm->p,1);
400
    scale(pm->pd,pm->p,1);
381
    pm->p[2]=rint(pm->pd[2]*xscale); pm->p[3]=rint(pm->pd[3]*yscale);
401
    pm->p[2]=rint(pm->pd[2]*xscale); pm->p[3]=rint(pm->pd[3]*yscale);
382
    if(pm->fill) {
402
    if(pm->fill) {
383
      gdImageArc(image,pm->p[0],pm->p[1],pm->p[2],pm->p[3],0,360,
403
      gdImageArc(image,pm->p[0],pm->p[1],pm->p[2],pm->p[3],0,360,
384
               color_bounder);
404
               color_bounder);
385
      patchgdImageFillToBorder(image,pm->p[0],pm->p[1],
405
      patchgdImageFillToBorder(image,pm->p[0],pm->p[1],
386
                      color_bounder,pm->color[0]);
406
                      color_bounder,pm->color[0]);
387
    }
407
    }
388
    gdImageArc(image,pm->p[0],pm->p[1],pm->p[2],pm->p[3],0,360,pm->color[0]);
408
    gdImageArc(image,pm->p[0],pm->p[1],pm->p[2],pm->p[3],0,360,pm->color[0]);
389
    if(vimg_enable) vimg_ellipse(scale_buf[0],scale_buf[1],0.5*pm->pd[2],0.5*pm->pd[3]);
409
    if(vimg_enable) vimg_ellipse(scale_buf[0],scale_buf[1],0.5*pm->pd[2],0.5*pm->pd[3]);
390
}
410
}
391
 
411
 
392
/* Circle */
412
/* Circle */
Line 406... Line 426...
406
/* flood fill */
426
/* flood fill */
407
void obj_fill(objparm *pm)
427
void obj_fill(objparm *pm)
408
{
428
{
409
    scale(pm->pd,pm->p,1);
429
    scale(pm->pd,pm->p,1);
410
    patchgdImageFill(image,pm->p[0],pm->p[1],pm->color[0]);
430
    patchgdImageFill(image,pm->p[0],pm->p[1],pm->color[0]);
411
}
431
}
412
 
432
 
413
/* flood fill to border*/
433
/* flood fill to border*/
414
void obj_fillb(objparm *pm)
434
void obj_fillb(objparm *pm)
415
{
435
{
416
    scale(pm->pd,pm->p,1);
436
    scale(pm->pd,pm->p,1);
417
    patchgdImageFillToBorder(image,pm->p[0],pm->p[1],pm->color[0],pm->color[1]);
437
    patchgdImageFillToBorder(image,pm->p[0],pm->p[1],pm->color[0],pm->color[1]);
418
}
438
}
419
 
439
 
420
gdImagePtr himg;
440
gdImagePtr himg;
421
 
441
 
422
int makehatchimage(int x, int y, int px, int py, int col)
442
int makehatchimage(int x, int y, int px, int py, int col)
423
{
443
{
Line 455... Line 475...
455
          if(width>1) {
475
          if(width>1) {
456
            gdImageLine(himg,-ax,ay-1,-1,0,c);
476
            gdImageLine(himg,-ax,ay-1,-1,0,c);
457
            gdImageLine(himg,ax,ay-1,2*ax-1,0,c);
477
            gdImageLine(himg,ax,ay-1,2*ax-1,0,c);
458
            gdImageLine(himg,0,-1,ax-1,-ay,c);
478
            gdImageLine(himg,0,-1,ax-1,-ay,c);
459
            gdImageLine(himg,0,2*ay-1,ax-1,ay,c);
479
            gdImageLine(himg,0,2*ay-1,ax-1,ay,c);
460
          }
480
          }
461
          break;
481
          break;
462
      }
482
      }
463
      case 1: {
483
      case 1: {
464
          gdImageLine(himg,0,0,ax-1,ay-1,c);
484
          gdImageLine(himg,0,0,ax-1,ay-1,c);
465
          if(width>1) {
485
          if(width>1) {
Line 471... Line 491...
471
          break;
491
          break;
472
      }
492
      }
473
      case 2: gdImageLine(himg,0,ay/2,ax-1,ay/2,c); break;
493
      case 2: gdImageLine(himg,0,ay/2,ax-1,ay/2,c); break;
474
      case 3: gdImageLine(himg,ax/2,0,ax/2,ay-1,c); break;
494
      case 3: gdImageLine(himg,ax/2,0,ax/2,ay-1,c); break;
475
    }
495
    }
476
    gdImageSetTile(image,himg);
496
    gdImageSetTile(image,himg);
477
    patchgdImageFill(image,pm->p[0],pm->p[1],gdTiled);
497
    patchgdImageFill(image,pm->p[0],pm->p[1],gdTiled);
478
    gdImageDestroy(himg);
498
    gdImageDestroy(himg);
479
    if(tiled) gdImageSetTile(image,tileimg);
499
    if(tiled) gdImageSetTile(image,tileimg);
480
}
500
}
481
 
501
 
482
/* flood fill with grid */
502
/* flood fill with grid */
483
void obj_gridfill(objparm *pm)
503
void obj_gridfill(objparm *pm)
484
{
504
{
485
    int nx,ny, c;
505
    int nx,ny, c;
486
    scale(pm->pd,pm->p,1);
506
    scale(pm->pd,pm->p,1);
487
    nx=pm->pd[2]; ny=pm->pd[3]; nx=abs(nx); ny=abs(ny);
507
    nx=pm->pd[2]; ny=pm->pd[3]; nx=abs(nx); ny=abs(ny);
488
    if(nx==0 && ny==0) {fly_error("bad grid size"); return;}
508
    if(nx==0 && ny==0) {fly_error("bad grid size"); return;}
489
    c=makehatchimage(nx,ny,pm->p[0],pm->p[1],pm->color[0]);
509
    c=makehatchimage(nx,ny,pm->p[0],pm->p[1],pm->color[0]);
490
    gdImageLine(himg,0,ny/2,nx-1,ny/2,c); gdImageLine(himg,nx/2,0,nx/2,ny-1,c);
510
    gdImageLine(himg,0,ny/2,nx-1,ny/2,c); gdImageLine(himg,nx/2,0,nx/2,ny-1,c);
491
    gdImageSetTile(image,himg);
511
    gdImageSetTile(image,himg);
492
    patchgdImageFill(image,pm->p[0],pm->p[1],gdTiled);
512
    patchgdImageFill(image,pm->p[0],pm->p[1],gdTiled);
493
    gdImageDestroy(himg);
513
    gdImageDestroy(himg);
494
    if(tiled) gdImageSetTile(image,tileimg);
514
    if(tiled) gdImageSetTile(image,tileimg);
495
}
515
}
496
 
516
 
497
/* flood fill with double hatching */
517
/* flood fill with double hatching */
498
void obj_diafill(objparm *pm)
518
void obj_diafill(objparm *pm)
499
{
519
{
Line 501... Line 521...
501
    scale(pm->pd,pm->p,1);
521
    scale(pm->pd,pm->p,1);
502
    nx=pm->pd[2]; ny=pm->pd[3]; nx=abs(nx); ny=abs(ny);
522
    nx=pm->pd[2]; ny=pm->pd[3]; nx=abs(nx); ny=abs(ny);
503
    if(nx==0 && ny==0) {fly_error("bad grid size"); return;}
523
    if(nx==0 && ny==0) {fly_error("bad grid size"); return;}
504
    c=makehatchimage(nx,ny,pm->p[0],pm->p[1],pm->color[0]);
524
    c=makehatchimage(nx,ny,pm->p[0],pm->p[1],pm->color[0]);
505
    gdImageLine(himg,0,0,nx-1,ny-1,c); gdImageLine(himg,0,ny-1,nx-1,0,c);
525
    gdImageLine(himg,0,0,nx-1,ny-1,c); gdImageLine(himg,0,ny-1,nx-1,0,c);
506
    gdImageSetTile(image,himg);
526
    gdImageSetTile(image,himg);
507
    patchgdImageFill(image,pm->p[0],pm->p[1],gdTiled);
527
    patchgdImageFill(image,pm->p[0],pm->p[1],gdTiled);
508
    gdImageDestroy(himg);
528
    gdImageDestroy(himg);
509
    if(tiled) gdImageSetTile(image,tileimg);
529
    if(tiled) gdImageSetTile(image,tileimg);
510
}
530
}
511
 
531
 
512
/* flood fill with double hatching */
532
/* flood fill with double hatching */
513
void obj_dotfill(objparm *pm)
533
void obj_dotfill(objparm *pm)
514
{
534
{
Line 599... Line 619...
599
    gdImageDestroy(insimg);
619
    gdImageDestroy(insimg);
600
}
620
}
601
 
621
 
602
/* copy an image file, with resizing */
622
/* copy an image file, with resizing */
603
void obj_copyresize(objparm *pm)
623
void obj_copyresize(objparm *pm)
604
{
624
{
605
    char *pp;
625
    char *pp;
606
    FILE *inf;
626
    FILE *inf;
607
    gdImagePtr insimg;
627
    gdImagePtr insimg;
608
 
628
 
609
    pp=find_word_start(pm->str);*find_word_end(pp)=0;
629
    pp=find_word_start(pm->str);*find_word_end(pp)=0;
610
    inf=open4read(pp);
630
    inf=open4read(pp);
611
    if(inf==NULL) {
631
    if(inf==NULL) {
612
      fly_error("file_not_found"); return;
632
      fly_error("file_not_found"); return;
Line 701... Line 721...
701
/* set linewidth */
721
/* set linewidth */
702
void obj_linewidth(objparm *pm)
722
void obj_linewidth(objparm *pm)
703
{
723
{
704
    if(pm->pd[0]<1 || pm->pd[0]>255) fly_error("bad_parms");
724
    if(pm->pd[0]<1 || pm->pd[0]>255) fly_error("bad_parms");
705
    else width=pm->pd[0];
725
    else width=pm->pd[0];
-
 
726
}
-
 
727
 
-
 
728
/* set crosshairsize */
-
 
729
void obj_crosshairsize(objparm *pm)
-
 
730
{
-
 
731
    if(pm->pd[0]<1 || pm->pd[0]>255) fly_error("bad_parms");
-
 
732
    else width2=pm->pd[0];
706
}
733
}
707
 
734
 
708
/* set x range */
735
/* set x range */
709
void obj_xrange(objparm *pm)
736
void obj_xrange(objparm *pm)
710
{
737
{