Back to index

wims  3.65+svn20090927
Functions
lines.c File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void error (char *p)
int ggetline (char buf[])
double getvar (char *p)
void setvar (char *p, double v)
char * find_name_end (char *p)
char * find_name_start (char *p)
void collapse_item (char *p, int n)
int getcolor (int r, int g, int b)
int widthcolor (int w, int color)
void scale (double dbuf[], int ibuf[], int cnt)
void scale2 (double xin, double yin, double *xout, double *yout)

Function Documentation

void collapse_item ( char *  p,
int  n 
)

Definition at line 78 of file lines.c.

{
    int i;
    char *pp;
    if(n<1) return;
    for(i=1,pp=strchr(p,','); i<n && pp!=NULL; i++,pp=strchr(pp+1,','));
    if(pp==NULL) *p=0;
    else strcpy(p,pp+1);
}

Here is the caller graph for this function:

void error ( char *  p)

Definition at line 20 of file lines.c.

{
    fprintf(stderr,"%s %d\n",p,linecnt);
}
char* find_name_end ( char *  p)

Definition at line 63 of file lines.c.

{
    int i;
    for(i=0;isalnum(*p) && i<MAX_LINELEN; p++,i++);
    return p;
}

Here is the caller graph for this function:

char* find_name_start ( char *  p)

Definition at line 71 of file lines.c.

{
    int i;
    for(i=0; !isalpha(*p) && i<MAX_LINELEN; p++,i++);
    return p;
}

Here is the caller graph for this function:

int getcolor ( int  r,
int  g,
int  b 
)

Definition at line 88 of file lines.c.

{
    int col;
    if(r>255) r=255; if(r<0) r=0;
    if(g>255) g=255; if(g<0) g=0;
    if(b>255) b=255; if(b<0) b=0;
    col=gdImageColorExact(image, r, g, b);
    if(col==-1) col=gdImageColorAllocate(image,r,g,b);
    return col;
}

Here is the call graph for this function:

Here is the caller graph for this function:

double getvar ( char *  p)

Definition at line 40 of file lines.c.

{
    int i;
    for(i=0;i<varcnt && strcmp(p,vartab[i].name)!=0;i++);
    if(i<varcnt) return vartab[i].value;
    else return 0;
}
int ggetline ( char  buf[])

Definition at line 27 of file lines.c.

{
    int c;
    int i;
    for(i=0,c=getchar();i<MAX_LINELEN;i++,c=getchar()) {
       if(c=='\n' || c==EOF) break;
       buf[i]=c;
    }
    buf[i]=0; 
    if(linecnt!=-100000) linecnt++;
    return c;
}

Here is the caller graph for this function:

void scale ( double  dbuf[],
int  ibuf[],
int  cnt 
)

Definition at line 149 of file lines.c.

{
    int i; double x,y;
    for(i=0;i<cnt*2 && i<MAX_PARMS;i+=2) {
       if(transform) {
           x=dbuf[i]*matrix[0]+dbuf[i+1]*matrix[1];
           y=dbuf[i]*matrix[2]+dbuf[i+1]*matrix[3];
       }
       else {x=dbuf[i]; y=dbuf[i+1];}
       scale_buf[i]=x+transx; scale_buf[i+1]=y+transy;
       ibuf[i]=rint((x-xstart+transx)*xscale);
       ibuf[i+1]=rint((y-ystart+transy)*yscale);
       if(ibuf[i]<-BOUND) ibuf[i]=-BOUND;if(ibuf[i]>BOUND) ibuf[i]=BOUND;
       if(ibuf[i+1]<-BOUND) ibuf[i+1]=-BOUND;if(ibuf[i+1]>BOUND) ibuf[i+1]=BOUND;
    }
}

Here is the caller graph for this function:

void scale2 ( double  xin,
double  yin,
double *  xout,
double *  yout 
)

Definition at line 167 of file lines.c.

{
    if(transform) {
       *xout=xin*matrix[0]+yin*matrix[1];
       *yout=xin*matrix[2]+yin*matrix[3];
    }
    else {
       *xout=xin; *yout=yin;
    }
    *xout*=xscale; *yout*=yscale;
}

Here is the caller graph for this function:

void setvar ( char *  p,
double  v 
)

Definition at line 48 of file lines.c.

{
    int i;
    if((strlen(p)>2 && strcmp(p,"animstep")!=0) || !isalpha(*p)) return;
    for(i=0;i<varcnt && strcmp(p,vartab[i].name)!=0;i++);
    if(i<varcnt) {vartab[i].value=v; return;}
    else {
       if(varcnt>=MAX_VARS || varnameptr>=varnamebuf+sizeof(varnamebuf)-1) return;
       strcpy(varnameptr,p);
       vartab[varcnt].name=varnameptr; vartab[varcnt].value=v;
       varnameptr+=strlen(varnameptr)+1; (varcnt)++;
    }
}
int widthcolor ( int  w,
int  color 
)

Definition at line 99 of file lines.c.

{
    int bg,fg,sh,e;
           /* already allocated */
    if(wimg!=NULL && savew==w && wcolor==color) goto end;
    if(wimg!=NULL) gdImageDestroy(wimg);
    wimg=gdImageCreate(w,w);
    if(wimg==NULL) {
       error("width_creation_failure"); return color;
    }
    bg=gdImageColorAllocate(wimg,255,255,255);
    gdImageColorTransparent(wimg,bg);
    fg=gdImageColorAllocate(wimg,gdImageRed(image,color),
                         gdImageGreen(image,color),
                         gdImageBlue(image,color));
    e=w-1;sh=e/3;
    switch(w) {
       case 2: {
           gdImageFill(wimg,0,0,fg); break;
       }
       case 3: {
           gdImageFill(wimg,0,0,fg); 
           gdImageSetPixel(wimg,2,0,bg);gdImageSetPixel(wimg,2,2,bg);
           break;
       }
       case 4:
       case 5:
       case 6:
       case 7: 
       case 8:
       case 9:
       case 10:
       case 11:
       case 12: {
           int pl[]={0,sh, sh,0, e-sh,0, e,sh,
                e,e-sh, e-sh,e, sh,e, 0,e-sh};
           gdImageFilledPolygon(wimg,(gdPointPtr) pl,8,fg);
           break;
       }
       default: {
           gdImageArc(wimg,w/2,w/2,w,w,0,360,fg);
           gdImageFillToBorder(wimg,w/2,w/2,fg,fg);
           break;
       }
    }
    savew=w; wcolor=color;
    end: gdImageSetBrush(image,wimg); return gdBrushed;
}

Here is the call graph for this function:

Here is the caller graph for this function: