示例#1
0
文件: rod_ctrl.c 项目: cyamauch/eggx
int main(int argc, char **argv)
{
  int win;
  double angle = 10, run = 0, reset = 0, quit = 0;
  double t = 0, h = 0.0001;
  param_set prms = {&win, &angle, &t, &run, &reset};

  e_ctrl ctrls[] = {
    {"Initial Angle", &angle, 1, &init, &prms},
    {"_Run", &run, 0, NULL, NULL},
    {"_Reset", &reset, 0, &init, &prms},
    {"_Quit", &quit, 0, NULL, NULL}
  };
  int cwin;
  cwin = init_ctrls(ctrls, 4);

  gsetinitialbgcolor(ECTRL_BGCOLOR);
  win = gopen(WD, HT);
  newlinewidth(win, 6);
  window(win, -WD/2, -MG, WD/2, HT-MG);
  layer(win, 0, 1);
  init(&prms);
  gsetnonblock(ENABLE);

  while (!quit) {
    int iscwin, type, button;
    double wx, wy;
    iscwin = ggetxpress(&type, &button, &wx, &wy);
    display_ctrls(cwin, ctrls, 4, wx, wy, iscwin, type, button);
    if (run) {
      rk4fixv6(rod, t, prms.r, h);
      t += h;
      if ((int)(t*RH) % (RH/100) == 0 ) {
        draw(&prms); msleep(10);
      }
      if (prms.r[0] >= M_PI/2) {
         run = 0;
         post(&prms);
      }
    }
  }
  gcloseall();

  return 0;
}
示例#2
0
static void btree(int win, Cdbl z1, Cdbl z2,
		  int dim, float rt, double ra, double rnd)
{
  Cdbl z3, z4, z5;

  if (dim == -1)
    return;
  z3 = z1 * rt + z2 * (1 - rt);
  z4 = z3 + rt * (z2 -
		  z1) * cexp(I * ra / 180 * M_PI * (rnd * drand48() +
						    (1 - rnd / 2)));
  z5 = z3 + rt * (z2 -
		  z1) * cexp(-I * ra / 180 * M_PI * (rnd * drand48() +
						     (1 - rnd / 2)));
  moveto(win, creal(z1), cimag(z1));
  newlinewidth(win, dim);
  lineto(win, creal(z3), cimag(z3));
  btree(win, z3, z5, dim - 1, rt, ra, rnd);
  btree(win, z3, z4, dim - 1, rt, ra, rnd);
}
示例#3
0
/*下の葉っぱを描く関数*/
void underleaf(void){
  float x7[49], y7[49];//座標の配列

  /*葉っぱ部分*/
  newhsvcolor(win, 122, 255, 200);//色指定

  x7[0]=648.0;    y7[0]=588.0;
  x7[1]=640.0;    y7[1]=585.0;
  x7[2]=636.0;    y7[2]=580.0;
  x7[3]=628.0;    y7[3]=572.0;
  x7[4]=618.0;    y7[4]=570.0;
  x7[5]=609.0;    y7[5]=562.0;
  x7[6]=606.0;    y7[6]=555.0;
  x7[7]=594.0;    y7[7]=527.0;
  x7[8]=589.0;    y7[8]=519.0;
  x7[9]=587.0;    y7[9]=513.0;
  x7[10]=588.0;    y7[10]=504.0;
  x7[11]=585.0;    y7[11]=503.0;
  x7[12]=587.0;    y7[12]=490.0;
  x7[13]=588.0;    y7[13]=481.0;
  x7[14]=593.0;    y7[14]=472.0;
  x7[15]=595.0;    y7[15]=466.0;
  x7[16]=604.0;    y7[16]=466.0;
  x7[17]=606.0;    y7[17]=468.0;
  x7[18]=607.0;    y7[18]=453.0;
  x7[19]=625.0;    y7[19]=431.0;
  x7[20]=642.0;    y7[20]=418.0;
  x7[21]=646.0;    y7[21]=415.0;
  x7[22]=648.0;    y7[22]=412.0;
  x7[23]=658.0;    y7[23]=412.0;
  x7[24]=658.0;    y7[24]=408.0;
  x7[25]=689.0;    y7[25]=410.0;
  x7[26]=692.0;    y7[26]=415.0;
  x7[27]=692.0;    y7[27]=456.0;
  x7[28]=688.0;    y7[28]=459.0;
  x7[29]=695.0;    y7[29]=477.0;
  x7[30]=696.0;    y7[30]=470.0;
  x7[31]=699.0;    y7[31]=470.0;
  x7[32]=698.0;    y7[32]=494.0;
  x7[33]=701.0;    y7[33]=500.0;
  x7[34]=704.0;    y7[34]=499.0;
  x7[35]=707.0;    y7[35]=496.0;
  x7[36]=712.0;    y7[36]=496.0;
  x7[37]=712.0;    y7[37]=507.0;
  x7[38]=706.0;    y7[38]=515.0;
  x7[39]=705.0;    y7[39]=522.0;
  x7[40]=700.0;    y7[40]=533.0;
  x7[41]=700.0;    y7[41]=543.0;
  x7[42]=691.0;    y7[42]=558.0;
  x7[43]=677.0;    y7[43]=567.0;
  x7[44]=673.0;    y7[44]=574.0;
  x7[45]=669.0;    y7[45]=584.0;
  x7[46]=662.0;    y7[46]=587.0;
  x7[47]=651.0;    y7[47]=587.0;
  x7[48]=654.0;    y7[48]=589.0;
  
  fillpoly(win, x7, y7, 49, 0);
  
  /*葉脈を描く*/
  newlinewidth(win, THICK);//葉脈の太さ指定
  newhsvcolor(win, 122, 153, 255);//色指定
  
  moveto(win, 650, 587);/*主となる部分(左下まで)*/
  lineto(win, 650, 574);
  lineto(win, 650, 553);
  lineto(win, 650, 519);
  lineto(win, 649, 491);
  lineto(win, 647, 458);
  lineto(win, 643, 445);
  
  moveto(win, 650, 574);/*左上1*/
  lineto(win, 645, 565);
  
  moveto(win, 650, 553);/*左上2*/
  lineto(win, 640, 524);
  lineto(win, 606, 482);
    
  moveto(win, 650, 519);/*右上2*/
  lineto(win, 661, 508);
  lineto(win, 665, 496);
  
  moveto(win, 649, 491);/*右下3*/
  lineto(win, 656, 483);
  lineto(win, 659, 468);
  lineto(win, 666, 457);
  lineto(win, 675, 439);
  
  moveto(win, 654, 568);/*右上1*/
  lineto(win, 662, 553);
  lineto(win, 667, 548);
  lineto(win, 677, 536);
  lineto(win, 689, 516);
}
示例#4
0
/*水滴が落ちる部分の葉っぱ(一番上)*/
void mainleaf(void){
  float x3[41], y3[41];//座標の配列

  /*葉っぱ部分*/
  newhsvcolor(win, 122, 255, 200);//色指定
  x3[0]=416.0;    y3[0]=767.0;
  x3[1]=419.0;    y3[1]=763.0;
  x3[2]=352.0;    y3[2]=759.0;
  x3[3]=288.0;    y3[3]=718.0;
  x3[4]=312.0;    y3[4]=719.0;
  x3[5]=307.0;    y3[5]=711.0;
  x3[6]=305.0;    y3[6]=707.0;
  x3[7]=303.0;    y3[7]=696.0;
  x3[8]=300.0;    y3[8]=695.0;
  x3[9]=300.0;    y3[9]=692.0;
  x3[10]=286.0;    y3[10]=661.0;
  x3[11]=281.0;    y3[11]=657.0;
  x3[12]=281.0;    y3[12]=651.0;
  x3[13]=277.0;    y3[13]=647.0;
  x3[14]=272.0;    y3[14]=628.0;
  x3[15]=271.0;    y3[15]=624.0;
  x3[16]=270.0;    y3[16]=613.0;
  x3[17]=275.0;    y3[17]=613.0;
  x3[18]=293.0;    y3[18]=613.0;
  x3[19]=295.0;    y3[19]=615.0;
  x3[20]=305.0;    y3[20]=615.0;
  x3[21]=342.0;    y3[21]=627.0;
  x3[22]=343.0;    y3[22]=621.0;
  x3[23]=370.0;    y3[23]=635.0;
  x3[24]=383.0;    y3[24]=636.0;
  x3[25]=399.0;    y3[25]=647.0;
  x3[26]=418.0;    y3[26]=669.0;
  x3[27]=421.0;    y3[27]=676.0;
  x3[28]=423.0;    y3[28]=671.0;
  x3[29]=427.0;    y3[29]=679.0;
  x3[30]=428.0;    y3[30]=686.0;
  x3[31]=429.0;    y3[31]=688.0;
  x3[32]=428.0;    y3[32]=702.0;
  x3[33]=431.0;    y3[33]=705.0;
  x3[34]=434.0;    y3[34]=709.0;
  x3[35]=434.0;    y3[35]=718.0;
  x3[36]=427.0;    y3[36]=731.0;
  x3[37]=428.0;    y3[37]=753.0;
  x3[38]=432.0;    y3[38]=748.0;
  x3[39]=432.0;    y3[39]=759.0;
  x3[40]=424.0;    y3[40]=763.0;
  
  fillpoly(win, x3, y3, 41, 0);
  
  /*葉脈を描く*/
  newlinewidth(win, THICK);//太さの指定
  newhsvcolor(win, 122, 153, 255);//色指定
  
  moveto(win, 428, 761);/*主となる部分*/
  lineto(win, 416, 749);
  lineto(win, 402, 739);
  lineto(win, 394, 732);
  lineto(win, 383, 723);
  lineto(win, 361, 698);
  lineto(win, 357, 692);
  lineto(win, 325, 660);
  lineto(win, 319, 651);
  lineto(win, 315, 644);
  lineto(win, 289, 626);
  
  moveto(win, 402, 739);/*左上部分*/
  lineto(win, 391, 736);
  lineto(win, 369, 731);
  lineto(win, 352, 730);
  
  moveto(win, 394, 732);/*右上部分*/
  lineto(win, 389, 686);
  
  moveto(win, 361, 698);/*左中部分*/
  lineto(win, 342, 691);
  lineto(win, 327, 686);
  lineto(win, 313, 685);
  
  moveto(win, 357, 692);/*右中部分*/
  lineto(win, 351, 649);
  
  moveto(win, 319, 651);/*左下部分*/
  lineto(win, 299, 646);
  lineto(win, 287, 646);
  
  moveto(win, 315, 644);/*右下部分*/
  lineto(win, 309, 632);
  lineto(win, 307, 623);
}
示例#5
0
/*右上の葉っぱの描画関数*/
void rightleaf(void){
  float x5[29], y5[29];//座標の配列
  
  /*葉っぱ部分*/
  newhsvcolor(win, 122, 255, 200);

  x5[0]=616.0;    y5[0]=676.0;
  x5[1]=618.0;    y5[1]=679.0;
  x5[2]=628.0;    y5[2]=679.0;
  x5[3]=645.0;    y5[3]=692.0;
  x5[4]=676.0;    y5[4]=696.0;
  x5[5]=675.0;    y5[5]=692.0;
  x5[6]=690.0;    y5[6]=693.0;
  x5[7]=693.0;    y5[7]=690.0;
  x5[8]=690.0;    y5[8]=684.0;
  x5[9]=699.0;    y5[9]=680.0;
  x5[10]=706.0;    y5[10]=674.0;
  x5[11]=717.0;    y5[11]=667.0;
  x5[12]=733.0;    y5[12]=653.0;
  x5[13]=743.0;    y5[13]=633.0;
  x5[14]=747.0;    y5[14]=626.0;
  x5[15]=747.0;    y5[15]=619.0;
  x5[16]=741.0;    y5[16]=617.0;
  x5[17]=722.0;    y5[17]=617.0;
  x5[18]=721.0;    y5[18]=615.0;
  x5[19]=692.0;    y5[19]=617.0;
  x5[20]=691.0;    y5[20]=613.0;
  x5[21]=686.0;    y5[21]=612.0;
  x5[22]=685.0;    y5[22]=615.0;
  x5[23]=679.0;    y5[23]=619.0;
  x5[24]=670.0;    y5[24]=621.0;
  x5[25]=663.0;    y5[25]=629.0;
  x5[26]=639.0;    y5[26]=646.0;
  x5[27]=628.0;    y5[27]=661.0;
  x5[28]=614.0;    y5[28]=672.0;
  
  fillpoly(win, x5, y5, 29, 0);
  
  /*葉脈を描く*/
  newlinewidth(win, THICK);//葉脈の太さ
  newhsvcolor(win, 122, 153, 255);//色指定
  
  moveto(win, 614, 673);
  lineto(win, 638, 672);
  lineto(win, 680, 673);
  
  moveto(win, 652, 671);/*主となる部分*/
  lineto(win, 684, 663);
  lineto(win, 689, 659);
  lineto(win, 705, 647);
  lineto(win, 717, 640);
  lineto(win, 727, 637);
  lineto(win, 731, 632);
  lineto(win, 739, 627);
  
  moveto(win, 689, 659);/*中上*/
  lineto(win, 702, 659);
  lineto(win, 710, 657);
  
  moveto(win, 667, 665);/*下1*/
  lineto(win, 674, 662);
  lineto(win, 680, 638);
    
  moveto(win, 705, 645);/*下2*/
  lineto(win, 715, 625);  
}