Ejemplo n.º 1
0
int init_image(Stimulus *st,  Substim *sst)
{

	int i,j,*p;
	double val,xval,yval,x,y,cval,cm,deg,sx,sy;
	Locator *pos = &st->pos;
	int ndots;

	if(sst->dotsiz[0] < 0.01)
	  sst->dotsiz[0] = deg2pix(0.08);
	if(sst->dotsiz[1] < 0.01)
	  sst->dotsiz[1] = deg2pix(0.08);
	if(pos->radius[0] < 0.1)
	  pos->radius[0] = deg2pix(2);
	if(pos->radius[0] > 2000)
	  pos->radius[0] = deg2pix(2);
	if(pos->radius[1] < 0.1)
	  pos->radius[1] = deg2pix(2);


	sst->pos.radius[0] = pos->radius[0];
	sst->pos.radius[1] = pos->radius[1];



	st->ndisps = 0;
	st->pos.locn[0] = 0;
	pos->phase = 0;
	st->phasedisp[0] = 0;
        memcpy(&sst->pos,&st->pos,sizeof(Locator));
	return(0);
}
Ejemplo n.º 2
0
void extent_bar(Stimulus *st, Rectangle *pr)
{
  int w,h;
   Locator *pos = &st->pos;

   h = pos->radius[0];
   w = deg2pix(1/st->f);
  pr->lx = (-pos->imsize[0]);
  pr->rx = (pos->imsize[0]);
  
  pr->ly = (pos->imsize[1]);
  pr->ry = -(pos->imsize[1]);
}
Ejemplo n.º 3
0
OneStim *NewBar(Stimulus *st,Substim *sst)
{
  OneStim *gb;
  float fval;

  if(st->pos.size[0] <= 1)
    st->pos.size[0] = 250;
  if(st->pos.size[1] <= 1)
    st->pos.size[1] = 10;
  fval = 2 * st->pos.radius[1];
  st->pos.imsize[1] = rint(fval + deg2pix(1/(2*st->f)));
  FreeStimulus(sst);
  if(sst->ptr == NULL)
    sst->ptr = (OneStim *)malloc(sizeof(OneStim));
  gb = sst->ptr;
  sst->nbars = 0;
  init_bar(st, sst);
  st->type = STIM_BAR;
  sst->type = STIM_BAR;
  return(gb);
}
Ejemplo n.º 4
0
void paint_bar(Stimulus *st, Substim *sst, int mode)
{
   Locator *pos = &sst->pos;
  int i,ci,w,h;
  float x[2],z[2],vcolor[3],*xc,*yc,*cc,*rc,cval;
  float angle,val;

    val = (st->background) * (1+ pos->contrast);
  if(pos->contrast > 2)
    val = 1.0;
  else if (st->background == 0)
    val = pos->contrast;
  cval = dogamma(val);
  vcolor[0] = vcolor[1] = vcolor[2] = cval;

  glPushMatrix();
  glTranslatef((pos->xy[0]),pos->xy[1],0);
  angle = (float) (pos->angle * 180.0/M_PI);
  glRotatef(angle,0,0,1);

  if(mode == LEFTMODE)
  {
    rc = cc = &vcolor[0];
  }
  else if(mode == RIGHTMODE)
  {
    cc = &vcolor[1];
    rc = &vcolor[2];
  }
   val = pos->phase;
   while(val > (2 * M_PI))
     val -= (M_PI * 2);

/*
* for bars, pos->f determines the width of the bar, while
* pos->radius[1] determines the field over which the bar moves
*/
   h = pos->radius[0];
   w = deg2pix(1/(2*st->f));
  z[0] = (-pos->radius[0]);
/*
 * if SQUARE, have constant velocity sweeps in one direction. Sign reversal 
 * is so that direction matches sines/rds
 */

  if(st->flag & STIMULUS_IS_SQUARE)
    z[1] = -w/2 - ((pos->radius[1]) * (val/M_PI -1));
  else
    z[1] = ((pos->radius[1]) * cos(val)) - w/2;
  glBegin(GL_POLYGON);
  mycolor(vcolor);	
  x[0] = z[0];
  x[1] = z[1];
  myvx(x);
  x[1] = z[1] + w;
  myvx(x);
  x[0] = z[0] +2 *  pos->radius[0];
  myvx(x);
  x[1] = z[1];
  myvx(x);
  glEnd();

  if(optionflag & ANTIALIAS_BIT)
    {
  glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
  glLineWidth(1.0);
  glEnable(GL_BLEND);
  glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
  glEnable(GL_LINE_SMOOTH);
  glBegin(GL_POLYGON);
  mycolor(vcolor);	
  x[0] = z[0];
  x[1] = z[1];
  myvx(x);
  x[1] = z[1] + w;
  myvx(x);
  x[0] = z[0] +2 *  pos->radius[0];
  myvx(x);
  x[1] = z[1];
  myvx(x);
  glEnd();
  glDisable(GL_BLEND);
  glDisable(GL_LINE_SMOOTH);
  glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
    }
  glPopMatrix();
  for(i = 0; i < sst->nbars; i++){
    glPushMatrix();
    glTranslatef(sst->xpos[i],sst->ypos[i],0);
    angle = (float) (sst->imb[i] * 180.0/M_PI);
    glRotatef(angle,0,0,1);
  glBegin(GL_POLYGON);
  mycolor(vcolor);	
  x[0] = z[0];
  x[1] = z[1];
  myvx(x);
  x[1] = z[1] + w;
  myvx(x);
  x[0] = z[0] +2 *  pos->radius[0];
  myvx(x);
  x[1] = z[1];
  myvx(x);
  glEnd();
    glPopMatrix();
      if(debug){
      glFlushRenderAPPLE();
          glSwapAPPLE();
      }
  }

}
Ejemplo n.º 5
0
void paint_square(Stimulus *st, Substim *sst, int mode)
{
    Locator *pos = &sst->pos;
    int i,ci,w,h,ncycles;
    short *p,*q,*end,vx,vy,*vpx,*vpy,*vpoy,*vpox;
    short x[2],z[2],*xc,*yc,c;
    float offcolor[3],vcolor[3],*rc,*cc;
    float angle, oldplaid;
    double val,cval;
    
    if(sst->ptr->plaid_angle < -0.1)
        val = (double)(st->background) * (1+ pos->contrast_amp);
    else
        val = (double)(st->background) * (1+ pos->contrast);
    if(st->background < 0.01 && pos->contrast > 0)
        val = pos->contrast;
    
    vcolor[0] = vcolor[1] = vcolor[2] = dogamma(val);
    
    if(sst->ptr->plaid_angle < -0.1)
        val = (double)(st->background) * (1- pos->contrast_amp);
    else
        val = (double)(st->background) * (1- pos->contrast);
    if(st->background < 0.01 && pos->contrast < 0)
        val = -pos->contrast;
    
    offcolor[0] = offcolor[1] = offcolor[2] = dogamma(val);
    
    glPushMatrix();
    glTranslatef((pos->xy[0]),pos->xy[1],0);
    angle  = (pos->angle+sst->ptr->plaid_angle/2) * 180/M_PI;
    glRotatef(angle,0.0,0.0,1.0);
    
    if(mode == LEFTMODE)
    {
        rc = cc = &vcolor[0];
    }
    else if(mode == RIGHTMODE)
    {
        cc = &vcolor[1];
        rc = &vcolor[2];
    }
    val = pos->phase;
    while(val > (2 * M_PI))
        val -= (M_PI * 2);
    
    /*
     * for ss, pos->f determines the width of the square, while
     * pos->radius[1] determines the field over which the squaren moves
     */
    h = pos->radius[0];
    w = deg2pix(1/(2*st->f));
    ncycles = pos->radius[1]/w;
    z[1] = -w * val/M_PI - (pos->radius[1]);
    z[0] = (-pos->radius[0]);
    while(z[1] < pos->radius[1])
    {
        mycolor(vcolor);	
        glBegin(GL_POLYGON);
        x[0] = z[0];
        x[1] = z[1];
        if(x[1] < -pos->radius[1])
            x[1] = -pos->radius[1];
        else if(x[1] > pos->radius[1])
            x[1] = pos->radius[1];
        myvx(x);
        x[1] = z[1] + w;
        if(x[1] < -pos->radius[1])
            x[1] = -pos->radius[1];
        else if(x[1] > pos->radius[1])
            x[1] = pos->radius[1];
        myvx(x);
        x[0] = z[0] +2 *  pos->radius[0];
        myvx(x);
        x[1] = z[1];
        if(x[1] < -pos->radius[1])
            x[1] = -pos->radius[1];
        else if(x[1] > pos->radius[1])
            x[1] = pos->radius[1];
        myvx(x);
        glEnd();
        z[1] += w;
        
        mycolor(offcolor);	
        glBegin(GL_POLYGON);
        x[0] = z[0];
        x[1] = z[1];
        if(x[1] < -pos->radius[1])
            x[1] = -pos->radius[1];
        else if(x[1] > pos->radius[1])
            x[1] = pos->radius[1];
        myvx(x);
        x[1] = z[1] + w;
        if(x[1] < -pos->radius[1])
            x[1] = -pos->radius[1];
        else if(x[1] > pos->radius[1])
            x[1] = pos->radius[1];
        myvx(x);
        x[0] = z[0] +2 *  pos->radius[0];
        myvx(x);
        x[1] = z[1];
        if(x[1] < -pos->radius[1])
            x[1] = -pos->radius[1];
        else if(x[1] > pos->radius[1])
            x[1] = pos->radius[1];
        myvx(x);
        glEnd();
        
        z[1] += w;
    }
    
    glPopMatrix();
    if(sst->ptr->plaid_angle > 0.01)
    {
        glDisable(GL_DEPTH_TEST);
        glDisable(GL_LIGHTING);
        glEnable(GL_BLEND);
        glBlendColor(0.5, 0.5, 0.5,  0.5);
        glBlendFunc (GL_ONE_MINUS_CONSTANT_COLOR, GL_CONSTANT_COLOR);
        oldplaid = sst->ptr->plaid_angle;
        sst->ptr->plaid_angle = -sst->ptr->plaid_angle;
        paint_square(st, sst, mode);
        glDisable(GL_BLEND);
        sst->ptr->plaid_angle = oldplaid;
    }
    
}