Exemplo n.º 1
0
void draw_rotated_axis_label(chan_info *cp, GdkGC *gc, const char *text, gint x0, gint y0)
{
  GtkWidget *w;
  if ((cp->chan > 0) && (cp->sound->channel_style == CHANNELS_COMBINED))
    w = channel_graph(cp->sound->chans[0]);
  else w = channel_graph(cp);
  rotate_text(w->window, gc, AXIS_LABEL_FONT(ss), text, 90, x0, y0);
}
Exemplo n.º 2
0
static void proctext(sdata_t *sdata, weed_timecode_t tc, char *xtext, cairo_t *cairo, PangoLayout *layout,
                     PangoFontDescription *font, int width, int height) {
  double dwidth,dheight;
  double radX,radY;

  switch (sdata->mode) {
  case (PT_WORD_COALESCE):

    if (sdata->timer==0.) {
      sdata->start=-1;
      sdata->length=1;
      sdata->tmode=PT_WORD_MODE;
    }

    if (sdata->start>-1) {
      set_font_size(layout,font,64);
      // get pixel size of word
      getlsize(layout, &dwidth, &dheight);

      setxypos(dwidth,dheight,width/2,height/2,&sdata->x_text,&sdata->y_text);

      sdata->dbl1-=sdata->dbl1/3.5+.5; // blur shrink
      sdata->dbl2+=.07;
      sdata->fg_alpha=sdata->dbl2;
    }

    if (sdata->alarm) {
      pt_subst_t *xsubst;
      char nxlast;

      sdata->bool1=!sdata->bool1;
      sdata->dbl1=300.; // blur start
      sdata->fg_alpha=sdata->dbl2=0.;

      if (sdata->length>0) {
        sdata->start++;
        if (sdata->start>=sdata->wlength) {
          sdata->start=0;
          sdata->length=0;
          sdata->dbl1=0.;
          pt_set_alarm(sdata,1000); // milliseconds
        }
      } else {
        sdata->length=1;
        sdata->bool1=TRUE;
      }

      if (sdata->length>0) {
        if (sdata->start==sdata->wlength-1) {
          pt_set_alarm(sdata,1000); // milliseconds
        } else {
          // peek at last char of next word
          if (sdata->text_type==TEXT_TYPE_ASCII) {
            xsubst=get_nth_word_ascii(sdata->text,sdata->start);
          } else {
            xsubst=get_nth_word_utf8(sdata->text,sdata->start);
          }

          nxlast=sdata->text[xsubst->start+xsubst->length-1];

          weed_free(xsubst);

          if (nxlast=='.'||nxlast=='!'||nxlast=='?') pt_set_alarm(sdata,1000); // milliseconds
          else if (nxlast==',') pt_set_alarm(sdata,700); // milliseconds
          else if (nxlast==';') pt_set_alarm(sdata,800); // milliseconds
          else pt_set_alarm(sdata,500); // milliseconds
        }
      }
    }

    break;

  case (PT_LETTER_STARFIELD):
    if (sdata->timer==0.) {
      sdata->start=0;
      sdata->length=0;

      sdata->tmode=PT_LETTER_MODE;

      sdata->letter_data=letter_data_create(sdata->tlength);
    }

    if (sdata->length>0) {
      pt_letter_data_t *ldt=&sdata->letter_data[sdata->count];
      double dist=ldt->zpos;
      if (dist>1.) {
        set_font_size(layout,font,1024./dist);

        // get pixel size of letter/word
        getlsize(layout, &dwidth, &dheight);

        sdata->x_text=ldt->xpos/dist+(double)width/2.;
        sdata->y_text=ldt->ypos/dist+(double)height/2.;

        setxypos(dwidth,dheight,sdata->x_text,sdata->y_text,&sdata->x_text,&sdata->y_text);

        sdata->fg_alpha=dist/100.+.5;

        anim_letter(ldt);

        colour_copy(&sdata->fg,&ldt->colour);

      } else pango_layout_set_text(layout, "", -1);

    }

    if (sdata->alarm) {
      // set values for next letter
      pt_letter_data_t *ldt=&sdata->letter_data[sdata->length];
      double angle=rand_angle();

      ldt->xpos=ldt->ypos=ldt->rot=ldt->rotvel=0.;
      ldt->zpos=80.+sdata->length;

      if (ldt->zpos>100.) ldt->zpos=100.;

      ldt->xvel=sin(angle)*16.;
      ldt->yvel=cos(angle)*16.;
      ldt->zvel=-2.;

      ldt->xaccel=ldt->yaccel=ldt->zaccel=ldt->rotaccel=0.;

      if (sdata->length==0||!strncmp(&sdata->text[utf8offs(sdata->text,sdata->length)]," ",1)) {
        ldt->colour.red=getrandi(60,255);
        ldt->colour.green=getrandi(60,255);
        ldt->colour.blue=getrandi(60,255);
      } else {
        colour_copy(&ldt->colour,&(sdata->letter_data[sdata->length-1].colour));
      }

      sdata->length++;

      if (sdata->length<sdata->tlength) pt_set_alarm(sdata,400); // milliseconds
      else pt_set_alarm(sdata,-1);
    }


    break;

  case (PT_SPINNING_LETTERS):
    if (sdata->timer==0.) {
      sdata->int1=0;

      // select all text
      sdata->start=0;
      sdata->length=sdata->tlength;

      sdata->tmode=PT_LETTER_MODE;
      sdata->dbl3=0.;
    }

    if (!sdata->count) {
      sdata->dbl1=0.;
      sdata->dbl2=sdata->dbl3;
      sdata->dbl3+=.1;
    }

    set_font_size(layout,font,64);

    sdata->x_text=width-sdata->int1+sdata->dbl1;
    sdata->y_text=height/2;

    // rotate letter
    rotate_text(cairo,layout,sdata->x_text,sdata->y_text,sdata->dbl2);

    // must re-center after rotating
    sdata->x_text=sdata->y_text=0;

    // get pixel size of letter/word
    getlsize(layout, &dwidth, &dheight);

    sdata->dbl1+=dwidth+10.;

    setxypos(0,dheight,sdata->x_text,sdata->y_text,&sdata->x_text,&sdata->y_text);

    if (sdata->alarm) {
      pt_set_alarm(sdata,25); // milliseconds
      // shift rate
      sdata->int1+=8;
    }

    // spin rate
    sdata->dbl2+=.1;

    break;

  case (PT_SPIRAL_TEXT):

    if (sdata->timer==0.) {
      sdata->int1=0;
      sdata->start=0;
      sdata->tmode=PT_LETTER_MODE;
    }

    set_font_size(layout,font,2560./(sdata->count+19.));

    // get pixel size of letter/word
    getlsize(layout, &dwidth, &dheight);

    // expansion factor
    if (sdata->int1<2) {
      sdata->dbl3=1.;
      sdata->bool1=FALSE;
    } else sdata->dbl3+=.0001;

    // set x_text, y_text
    if (!sdata->count) {
      sdata->dbl1=radX=width*.45*sdata->dbl3;
      sdata->dbl2=radY=height*.45*sdata->dbl3;
    } else {
      if (!sdata->bool1) {
        sdata->dbl1=radX=sdata->dbl1*.98;
        sdata->dbl2=radY=sdata->dbl2*.98;
      } else {
        sdata->dbl1=radX=sdata->dbl1*.97;
        sdata->dbl2=radY=sdata->dbl2*.97;
      }
    }

    if (sdata->bool1)
      setxypos(dwidth,dheight,width/2+sin(sdata->count/4.+(sdata->dbl3-1.)*9.)*radX,
               height/2-cos(-sdata->count/4.-(sdata->dbl3-1.)*8.)*radY,&sdata->x_text,&sdata->y_text);

    else
      setxypos(dwidth,dheight,width/2+sin(sdata->count/4.+(sdata->dbl3-1.)*8.)*radX,
               height/2-cos(-sdata->count/4.-(sdata->dbl3-1.)*8.)*radY,&sdata->x_text,&sdata->y_text);

    if (!strncmp(xtext,".",1)) sdata->int1++;

    if (sdata->alarm) {
      pt_set_alarm(sdata,250); // milliseconds
      if (sdata->start+sdata->length<sdata->tlength) {
        // add an extra letter
        sdata->length++;
      } else {
        sdata->length-=2;
        sdata->start+=2;
        sdata->dbl3-=.0002;

        sdata->dbl1=sdata->dbl1*.97;
        sdata->dbl2=radY=sdata->dbl2*.97;

        // trip to lissajou
        if (!sdata->bool1) sdata->bool1=TRUE;

        if (sdata->length<=0) {
          sdata->length=1;
          sdata->start=0;
          sdata->bool1=FALSE;
          sdata->dbl3=-sdata->dbl3/12.;
        } else pt_set_alarm(sdata,50); // milliseconds

      }

    }
    break;

  } // end switch

}