void init(void *_prms) { param_set *p = (param_set *) _prms; int i, j; *p->mid = (L + 1) / 2; /* screen mid */ for (i = 0; i < L + 2; i++) for (j = 0; j < L + 2; j++) grid[i][j] = 0; grid[(int) *p->mid][(int) *p->mid] = 1; if (*p->R >= L) { while (*p->R >= L - 1) { *p->R -= dR; } } *p->src_r = 0; *p->new_r = 1; *p->rem_r = 0; *p->reset = 0; layer(*p->win, 0, 2); gsetbgcolor(*p->win, ECTRL_BGCOLOR); newcolor(*p->win, "#303030"); gclr(*p->win); fillarc(*p->win, *p->mid, *p->mid, *p->R / 2, *p->R / 2, 0, 360, 0); layer(*p->win, 0, 1); copylayer(*p->win, 2, 1); copylayer(*p->win, 1, 0); }
void draw(void *_prms) { param_set *p = (param_set *) _prms; int i; double psc = 2 * R / Hmax, vdistmax; gclr(*p->win); copylayer(*p->win, 2, 1); for (i = 0; i < DN; i++) { putimg24m(*p->win, x[i] - 4, y[i] - 4, 8, 8, Xpm_image_stone4); } copylayer(*p->win, 1, 0); gclr(*p->win2); vdistmax = vdist[0]; for (i = 0; i < Hmax; i++) { if (vdistmax < vdist[i]) vdistmax = vdist[i]; } newcolor(*p->win2, "steelblue4"); for (i = 0; i < Hmax; i++) { fillrect(*p->win2, psc * i, 0, psc, vdist[i] / vdistmax * R); } newcolor(*p->win2, "steelblue"); for (i = 0; i < Hmax; i++) { drawrect(*p->win2, psc * i, 0, psc, vdist[i] / vdistmax * R); } copylayer(*p->win2, 1, 0); }
int main() { time_t time_now ; int win ; char d0[8],d1[8],d2[8],d3[8], t0[16] ; gsetinitialattributes(ENABLE,DOCK_APPLICATION) ; win = gopen(56,56) ; layer(win,0,1) ; while(1){ time(&time_now) ; sscanf(ctime(&time_now),"%s %s %s %s %s\n",d0,d1,d2,t0,d3) ; gclr(win) ; newrgbcolor(win,0xff,0xff,0xff) ; drawstr(win,4,1, 8 ,0,"%s %s %s",d0,d1,d2) ; drawstr(win,4,46, 10 ,0,"%s",t0) ; gputimage(win,0,10,Ppmimage,PPM_WIDTH,PPM_HEIGHT,0) ; newrgbcolor(win,0x40,0x40,0x40) ; moveto(win,0,0) ; lineto(win,0,55) ; lineto(win,55,55) ; newrgbcolor(win,0xe7,0xe7,0xe7) ; lineto(win,55,0) ; lineto(win,0,0) ; copylayer(win,1,0) ; msleep(200) ; } gcloseall() ; return(0) ; }
int main() { int win ; time_t time_now ; char d0[8],d1[8],d2[8],d3[8], t0[16] ; /* open a graphic window */ win = gopen(FONTSIZE*24/2+4,FONTSIZE+4) ; /* set name of window */ winname(win,"Simple Clock") ; /* configure layer */ layer(win,0,1) ; /* display time... */ while(1){ time(&time_now) ; sscanf(ctime(&time_now),"%s %s %s %s %s",d0,d1,d2,t0,d3) ; gclr(win) ; drawstr(win,2,2,FONTSIZE,0,"%s %s %s %s %s",d0,d1,d2,t0,d3) ; copylayer(win,1,0) ; msleep(200) ; } /* close a graphic window */ gclose(win) ; return(0) ; }
void draw(void *_prms) { param_set *p = (param_set *) _prms; static double y[2 * WD], v[2 * WD]; int i; static int poincare = 0; for (i = 0; i < 2 * WD - 1; i++) { y[i] = y[i + 1]; v[i] = v[i + 1]; } y[2 * WD - 1] = p->r[0]; v[2 * WD - 1] = p->r[1]; /* y-t chart */ gclr(*p->win); newcolor(*p->win, "gold"); drawline(*p->win, MG, 0, 2 * WD + MG, 0); newcolor(*p->win, ECTRL_FGCOLOR); for (i = 0; i < 2 * WD; i++) { pset(*p->win, MG + i, y[i] * HT * SCY); } copylayer(*p->win, 1, 0); /* phase chart */ if (*p->clr2 == 1) { gclr(*p->win2); *p->clr2 = 0; } for (i = 0; i < 2 * WD; i++) { pset(*p->win2, y[i] * HT * SCY, v[i] * SCV); } copylayer(*p->win2, 1, 0); /* poincare chart */ if (*p->clr3 == 1) { gclr(*p->win3); *p->clr3 = 0; } if (poincare % 50 == 0) { pset(*p->win3, y[2 * WD - 1] * HT * SCY, v[2 * WD - 1] * SCV); copylayer(*p->win3, 1, 0); } poincare++; }
static void draw(int win, float snowx[], float snowy[], int nsnow) { int i; float *snowx_p; float *snowy_p; /* 1番は背景専用レイヤ */ layer(win, 0, 1); /* 背景色レイヤをコピー */ copylayer(win, 2, 1); /* 遠くの雪 */ newrgbcolor(win, 0x0bf, 0x0bf, 0x0bf); snowx_p = snowx; snowy_p = snowy; for (i = 0; i < nsnow / 2; i++) { snowx_p[i] += (2.0 * (drand48() - 0.5)) * 0.5; snowy_p[i] -= (2.5 + drand48()) * 0.5; if (snowy_p[i] <= 0.0) snowy_p[i] = L; } drawpts(win, snowx_p, snowy_p, nsnow / 2); /* 木(マスクつき)をコピー */ newgcfunction(win, GXand); gputarea(win, -L / 2, 0, win, 4, -L / 2, 0, L / 2 - 1, L - 1); newgcfunction(win, GXor); gputarea(win, -L / 2, 0, win, 3, -L / 2, 0, L / 2 - 1, L - 1); newgcfunction(win, GXcopy); /* 近くの雪 */ newrgbcolor(win, 0x0ff, 0x0ff, 0x0ff); snowx_p = snowx + nsnow / 2; snowy_p = snowy + nsnow / 2; for (i = 0; i < nsnow / 2; i++) { snowx_p[i] += 2.0 * (drand48() - 0.5); snowy_p[i] -= 2.5 + drand48(); if (snowy_p[i] <= 0.0) snowy_p[i] = L; } drawpts(win, snowx_p, snowy_p, nsnow / 2); copylayer(win, 1, 0); }
void post(void *_prms) { param_set *p = (param_set *) _prms; char omega[20]; double al = (*p->angle)*M_PI/180; newpen(*p->win, 1); sprintf(omega, "w = %.4f, %.4f\n", p->r[3], sqrt(3*G*cos(al)/(2*L))); drawstr(*p->win, -WD/2+MG, HT-3*MG, 14, 0, omega); copylayer(*p->win, 1, 0); }
int main() { int win; int cnt; float x_cen = X_CEN; float y_cen = Y_CEN; win = gopen(WIDTH,HEIGHT); puts("Move your mouse cursor on the window :-)"); /* レイヤの設定をする */ layer(win, 0,1); /* ノンブロックモードにする */ gsetnonblock(ENABLE); cnt = 0; while ( 1 ) { int win_ev; /* イベントのあったウィンドゥ番号 */ int type, b; /* イベントのタイプ,ボタン */ float r, x, y; win_ev = ggetevent(&type,&b,&x,&y) ; if ( win_ev == win ) { if ( type == MotionNotify ){ x_cen = x; y_cen = y; } else if ( type == ButtonPress ) { break; } } else { int i; if ( CNT_MAX <= cnt ) cnt = 0; gclr(win); for ( i=0 ; i < 4 ; i++ ) { r = pow((cnt+i*(CNT_MAX/4)) % CNT_MAX, 2)/DIV; drawcirc(win,x_cen,y_cen,r,r); } copylayer(win, 1,0); msleep(20); cnt++; } } gclose(win); return(0); }
void print_density(void *_prms) { param_set *p = (param_set *) _prms; int i, j, numt = 0, numa = 0; for (i = 0; i < L; i++) { for (j = 0; j < L; j++) { if (hypot(i - *p->mid, j - *p->mid) <= *p->src_r) numt++; numa += grid[i][j]; } } newcolor(*p->win, "cornsilk"); drawstr(*p->win, 100, 10, 14, 0, "Density = %.4f", numa / (double) numt); copylayer(*p->win, 1, 0); }
void init(void *_prms) { param_set *p = (param_set *) _prms; int i, j; double th; layer(*p->win, 0, 4); /* mask */ gsetbgcolor(*p->win, "black"); gclr(*p->win); newcolor(*p->win, "white"); fillcirc(*p->win, 0, 0, R, R); newcolor(*p->win, "black"); fillcirc(*p->win, *p->x0, 0, *p->IR, *p->IR); layer(*p->win, 0, 3); /* image-mapped wall and colored vacuum */ gsetbgcolor(*p->win, ECTRL_BGCOLOR); gclr(*p->win); for (i = 0; i < 2; i++) for (j = 0; j < 2; j++) putimg24(*p->win, (i - 1) * 200, (j - 1) * 200, 200, 200, Xpm_image_slope); newgcfunction(*p->win, GXandInverted); gputarea(*p->win, -R, -R, *p->win, 4, -R, -R, R, R); layer(*p->win, 0, 2); /* compose background image */ gclr(*p->win); newgcfunction(*p->win, GXand); gputarea(*p->win, -R, -R, *p->win, 4, -R, -R, R, R); newgcfunction(*p->win, GXor); gputarea(*p->win, -R, -R, *p->win, 3, -R, -R, R, R); newgcfunction(*p->win, GXcopy); layer(*p->win, 0, 1); copylayer(*p->win, 2, 1); /* copy background image */ for (i = 0; i < N; i++) { th = drand48() * 2 * M_PI; x[i] = 0.95 * R * cos(th); y[i] = 0.95 * R * sin(th); vx[i] = (drand48() - 0.5) * Hmax; vy[i] = drand48() * Hmax * sin(drand48() * 2 * M_PI); } *p->run = 0; getstatis(); draw(p); }
void draw(void *_prms) { param_set *p = (param_set *) _prms; double x, y ; double rad ; char tstr[20]; rad = p->r[0]; y = L*cos(rad)*SC; x = L*sin(rad)*SC; gclr(*p->win); sprintf(tstr, "t = %.4f", *p->t); newrgbcolor(*p->win, 204,153, 0); fillrect(*p->win, -WD/2, -MG, WD, 18); newpen(*p->win, 1); moveto(*p->win, -x, 0); lineto(*p->win, x, 2*y); drawstr(*p->win, -WD/2+MG, HT-2*MG, 14, 0, tstr); copylayer(*p->win, 1, 0); }
void draw(void *_prms) { param_set *p = (param_set *) _prms; double maskx[4], masky[4]; double rad; rad = *p->angle * M_PI / 180; maskx[0] = maskx[1] = *p->sx; maskx[2] = maskx[3] = *p->sx + 200; masky[0] = 0; masky[1] = masky[2] = 200; masky[3] = 200 * tan(*p->angle * M_PI / 180); gclr(*p->win); putimg24(*p->win, *p->sx, 0, 200, 200, Xpm_image_slope); newcolor(*p->win, ECTRL_BGCOLOR); fillpoly(*p->win, maskx, masky, 4, 0); putimg24m(*p->win, *p->bx - 10 * (sin(rad) + 1), *p->by + 10 * (cos(rad) - 1), 20, 20, Xpm_image_stone10); newcolor(*p->win, ECTRL_FGCOLOR); drawline(*p->win, X0 + L, 0, X0 + L, 220); copylayer(*p->win, 1, 0); }
void draw(void *_prms) { param_set *p = (param_set *) _prms; int id, aggr = 0, this_r; int x, y, xnt, ynt, tk, key = 0; float tx[50000], ty[50000], th; for (;;) { if (*p->new_r) { *p->new_r = 0; *p->src_r += *p->r_inc; *p->rem_r = *p->src_r + *p->r_inc; if (*p->src_r >= (*p->R / 2)) { *p->run = 0; print_density(p); break; } } th = drand48() * 2.0 * M_PI; x = *p->src_r * cos(th) + *p->mid; y = *p->src_r * sin(th) + *p->mid; tk = 0; while (*p->run) { id = floor(drand48() * 4.0); xnt = (id == 0) ? x - 1 : (id == 1) ? x + 1 : x; ynt = (id <= 1) ? y : (id == 2) ? y - 1 : y + 1; tx[tk] = xnt; ty[tk] = ynt; this_r = hypot(xnt - *p->mid, ynt - *p->mid); if ((xnt < *p->mid - *p->R) || (xnt >= *p->mid + *p->R) || (ynt < *p->mid - *p->R) || (ynt >= *p->mid + *p->R) || (this_r > *p->rem_r)) { newcolor(*p->win, "red4"); break; } /* seems to escape */ if (grid[xnt - 1][ynt] == 1 || grid[xnt][ynt - 1] == 1 || grid[xnt][ynt + 1] == 1 || grid[xnt + 1][ynt] == 1) { aggr = 1; if (drand48() <= *p->agg_prob) { grid[xnt][ynt] = 1; if (this_r >= *p->src_r) *p->new_r = 1; layer(*p->win, 0, 2); newcolor(*p->win, ECTRL_FGCOLOR); pset(*p->win, xnt, ynt); layer(*p->win, 0, 1); newcolor(*p->win, "green3"); } break; } /* aggregate */ if (aggr == 0) { x = xnt; y = ynt; } aggr = 0; tk++; } gclr(*p->win); copylayer(*p->win, 2, 1); newlinestyle(*p->win, LineSolid); drawpts(*p->win, tx, ty, tk - 1); newcolor(*p->win, "gray50"); newlinestyle(*p->win, LineOnOffDash); drawarc(*p->win, *p->mid, *p->mid, *p->src_r, *p->src_r, 0, 360, 0); copylayer(*p->win, 1, 0); msleep(5); key = ggetch(); if (key == 'q') { *p->run = 0; goto RET; } } RET: ; /* do nothing just return */ }
int main( int argc, char *argv[] ) { int ret = 1; int win_main, win_zoom, zoom_factor = 2; double p_x = -1, p_y = -1; unsigned char *zoom_buf = NULL; unsigned char *img_buf = NULL; int img_width, img_height, img_msk; int crosshairs = 1; if ( argc < 2 ) { fprintf(stderr,"[USAGE]\n"); fprintf(stderr,"%s filename.png\n",argv[0]); return 1; } /* zoom ウィンドゥ用の画像バッファ */ zoom_buf = (unsigned char *)malloc(ZOOMWN_WIDTH * ZOOMWN_HEIGHT * 4); if ( zoom_buf == NULL ) goto quit; //img_buf = readimage(NULL,argv[1],&img_width,&img_height,&img_msk); //img_buf = readimage("xbmtopbm",argv[1],&img_width,&img_height,&img_msk); #ifdef USE_IMAGEMAGICK img_buf = readimage("convert",argv[1],&img_width,&img_height,&img_msk); #else img_buf = readimage("pngtopnm",argv[1],&img_width,&img_height,&img_msk); #endif if ( img_buf == NULL ) { fprintf(stderr,"ERROR: cannot read file\n"); goto quit; } printf("mask value = %d\n",img_msk); /* 属性設定(左上を原点にする) */ gsetinitialattributes(DISABLE, BOTTOM_LEFT_ORIGIN); /* ウィンドゥのオープン */ win_zoom = gopen(ZOOMWN_WIDTH*2, ZOOMWN_HEIGHT); win_main = gopen(img_width, img_height); layer(win_zoom,0,1); /* メインウィンドゥへの画像の転送 */ gclr(win_main); gputimage(win_main, 0,0, img_buf, img_width, img_height, img_msk); /* カーソル描画のために,XOR での描画functionに設定 */ newgcfunction(win_main, GXxor); newcolor(win_main, "red"); #if 0 /* 保存のテスト */ //writeimage(img_buf,img_width,img_height,img_msk,"pnmtopng",256,"hoge.png"); //writeimage(img_buf,img_width,img_height,img_msk,NULL,256,"hoge.pam"); gsaveimage( win_main,0,0,0,1999,1999,"pnmtopng",256,"capt0.png"); { int im_w, im_h; unsigned char *im = ggetimage(win_main,0,0,0,1999,1999,&im_w,&im_h); writeimage(im_w,im_h,im,0,"pnmtopng",256,"capt.png"); if ( im != NULL ) free(im); } #endif /* メインループ */ while ( 1 ) { int win_ev, type, b; int needs_redraw = 0; double x, y; win_ev = ggetevent(&type,&b,&x,&y) ; if ( type == EnterNotify ) { fprintf(stderr,"event type = EnterNotify wid=%d\n",win_ev); } else if ( type == LeaveNotify ) { fprintf(stderr,"event type = LeaveNotify wid=%d\n",win_ev); } else { fprintf(stderr,"event type = %d wid=%d\n",type,win_ev); } if ( win_ev == win_main ) { if ( type == MotionNotify || type == EnterNotify || type == LeaveNotify ) { if ( type == LeaveNotify ) { x = -32000; y = -32000; } if ( crosshairs ) { /* crosshairs カーソルを消す */ drawline(win_main, 0,p_y, img_width,p_y); drawline(win_main, p_x,0, p_x,img_height); /* crosshairs カーソルを表示する */ drawline(win_main, 0,y, img_width,y); drawline(win_main, x,0, x,img_height); } needs_redraw = 1; p_x = x; p_y = y; } else if ( type == ButtonPress ) { if ( b == 1 ) zoom_factor++; else if ( b == 3 ) zoom_factor--; needs_redraw = 1; } } if ( type == KeyPress ) { if ( b == 'q' ) goto quit; else if ( b == '>' || b == '+' ) zoom_factor++; else if ( b == '<' || b == '-' ) zoom_factor--; else if ( b == ' ' ) { if ( crosshairs ) { /* crosshairs カーソルを消す */ drawline(win_main, 0,p_y, img_width,p_y); drawline(win_main, p_x,0, p_x,img_height); crosshairs = 0; } else { /* crosshairs カーソルを表示する */ drawline(win_main, 0,p_y, img_width,p_y); drawline(win_main, p_x,0, p_x,img_height); crosshairs = 1; } } needs_redraw = 1; } if ( needs_redraw ) { if ( zoom_factor < 2 ) zoom_factor = 2; else if ( 32 < zoom_factor ) zoom_factor = 32; get_zoom_image(img_width, img_height, img_buf, p_x, p_y, zoom_factor, ZOOMWN_WIDTH, ZOOMWN_HEIGHT, zoom_buf); gclr(win_zoom); /* 普通のコピー */ newgcfunction(win_zoom, GXcopy); gputimage(win_zoom, 0, 0, zoom_buf, ZOOMWN_WIDTH, ZOOMWN_HEIGHT, img_msk); /* 反転コピー */ newgcfunction(win_zoom, GXcopyInverted); gputarea(win_zoom, ZOOMWN_WIDTH, 0, win_zoom,1, 0,0,ZOOMWN_WIDTH-1, ZOOMWN_HEIGHT-1); /* ズームウィンドゥで,文字列を反転描画する */ newgcfunction(win_zoom, GXinvert); drawstr(win_zoom,2,14,14,0, "%dx zoom pos=(%g,%g)\n",zoom_factor,p_x,p_y); copylayer(win_zoom,1,0); } } ret = 0; quit: gcloseall(); if ( img_buf != NULL ) free(img_buf); if ( zoom_buf != NULL ) free(zoom_buf); return ret; }
int main() { int win, i, j, k, m, key = 0; int arp[5] = { 0, 3, 1, 4, 2 }, ars[7] = { 0, 5, 3, 1, 6, 4, 2}; double pentagon[3][5], septagon[3][7], parab[3][144], y; win = gopen(L, L); window(win, -L / 2, -L / 2, L / 2, L / 2); gsetbgcolor(win, ECTRL_BGCOLOR); newcolor(win, ECTRL_FGCOLOR); winname(win, "e_3d demo"); layer(win, 0, 1); gsetnonblock(ENABLE); i = j = m = 0; for (i = 0; i < 144; i++) { y = L/(2*144.0)*i; parab[0][i] = 0; parab[1][i] = -y; parab[2][i] = 0.02*y*(L/2 - y); } while (key != 'q') { g3dsetangle(torad(40 * (1.5 + sin(j * 2 * M_PI / 30))), i * 2 * M_PI / 144); gclr(win); for (k = 0; k < 5; k++) { pentagon[0][k] = L / 6 * cos(arp[k] * 2 * M_PI / 5 + m * 2 * M_PI / 50) + L / 5; pentagon[1][k] = L / 6 * sin(arp[k] * 2 * M_PI / 5 + m * 2 * M_PI / 50) + L / 5; pentagon[2][k] = 0; } for (k = 0; k < 7; k++) { septagon[0][k] = L / 6 * cos(ars[k] * 2 * M_PI / 7 + 2 * m * 2 * M_PI / 50) - L / 5; septagon[1][k] = 0; septagon[2][k] = L / 6 * sin(ars[k] * 2 * M_PI / 7 + 2 * m * 2 * M_PI / 50) + L / 5; } newcolor(win, "lightsteelblue"); newlinestyle(win, LineOnOffDash); for(k = 0; k < 6; k++) { drawline3d(win, -L/10*k, 0, 0, -L/10*k, -L/2, 0); drawline3d(win, 0, -L/10*k, 0, -L/2, -L/10*k, 0); } newlinestyle(win, LineSolid); newcolor(win, "red4"); fillpoly3d(win, pentagon[0], pentagon[1], pentagon[2], 5, 0); newcolor(win, "green4"); fillpoly3d(win, septagon[0], septagon[1], septagon[2], 7, 0); newcolor(win, ECTRL_FGCOLOR); drawarrow3d(win, 0, 0, 0, 0, 0, L / 3, 10, 6, 12); drawarrow3d(win, 0, 0, 0, 0, L / 3, 0, 10, 6, 12); drawarrow3d(win, 0, 0, 0, L / 3, 0, 0, 10, 6, 12); newcolor(win, "gold3"); drawstr3d(win, 0, 0, L/3+10, FONTSET, 0, "z¼´"); drawlines3d(win, parab[0], parab[1], parab[2], 144); y = L/(2*36.0)*(i%36); putimg24m3d(win, 0 - 6 *(-sin(_phi) - cos(_th)*cos(_phi)), -y - 6*(cos(_phi) - cos(_th)*sin(_phi)), 0.02*y*(L/2 - y) -6*sin(_th), 12, 12, Xpm_image_stone6); copylayer(win, 1, 0); i++; i %= 144; j++; j %= 30; m++; m %= 50; msleep(40); key = ggetch(); } gcloseall(); return 0; }
int main(){ int a, i;//カウンタ変数 int phase[MAXNUMBER];//波の位相の配列 int color[MAXNUMBER];//波の色の配列 int droparray[MAXNUMBER];//落ちる水滴の配列 float x;//円の中心x座標 float y;//円の中心y座標 float r[MAXNUMBER];//円の半径の配列 float scale;//減衰のための係数 float phasescale;//位相の減衰係数 float sum;//波を足し合わせる関数 int count;//カウント変数 int offset;//波の相殺 int flag;//フラグ変数 win=gopen(800,800);/*画面表示*/ winname(win,"final");/*題名*/ phasescale = 0.25; flag = 0; /*水滴の描画*/ for(a=0; a<=1; a++){ for(i=0; i<=150; i++){ background();//背景を描く関数 if(a==1){ newpen(win , 1); fillcirc(win, 270, 610, 6, 6); /*葉っぱの先の水滴を描く*/ } branch();//木の幹を書く関数 rightleaf();//上側の葉っぱを描く関数 underleaf();//下側の葉っぱを描く関数 mainleaf();//メインの葉っぱを描く関数 surfacewater();//水面を描く関数 newpen(win, 1); fillcirc(win, 426-i, 761-i, 5, 5); /*葉っぱの初期移動*/ msleep(50); } } /*波の初期設定*/ for(i=0; i < MAXNUMBER; i++){ color[i] = 128; phase[i] = -1; droparray[i]=-1; r[i]=(MAXLENGTH / MAXNUMBER) * i;//円の半径初期化 } x=300.0; y=300.0; layer(win, 0, 1); /*表示は 0 番、描画は 1 番レイヤーで*/ /*波が非同期に落ちる*/ while(1){ background();//背景を描く関数 /*葉っぱの先の水滴を描く*/ newpen(win , 1); fillcirc(win, 270, 610, 6, 6); branch();//木の幹を描く関数 rightleaf();//上側の葉っぱを描く関数 underleaf();//下側の葉っぱを描く関数 mainleaf();//メインの葉っぱを描く関数 surfacewater();//水面を描く関数 /*初期化*/ color[0] = 0; sum = 0; count = 0; for(i=0; i < MAXNUMBER; i++){ if(phase[i] >= 200){ phase[i] = -1; flag = 1; } if(phase[i] != -1){ scale = (MAXNUMBER - phase[i])*0.01; sum += 128*(sin(ENSHUU/MAXNUMBER-phasescale*phase[i])*scale); count++; msleep(3); } } if(count > 0){ color[0] = sum / count + 128 - offset; if(flag == 1){ offset += color[0] - color[1]; flag = 0; } if(offset > 0){ offset--; }else if(offset < 0){ offset++; } } if(color[0] == 0 || color[0] >= 255 ){ color[0] = 128; } for(i=MAXNUMBER-1; i>0; i--){ color[i]=color[i-1]; } for(i=MAXNUMBER-1; i>=0; i--) { if( r[i] > 0.0 ) { newhsvcolor(win, 200, color[i], 255); fillcirc(win, x, y, r[i], r[i]); } } if(drop(droparray) == 1){ for(i=0; i<MAXNUMBER; i++){ if(phase[i] == -1){ phase[i] = 0; break; } } } for(i=0; i<=MAXNUMBER; i++){ if(phase[i] != -1){ phase[i]++; } } copylayer(win, 1, 0); /*レイヤー 1 番の内容を 0 にコピー*/ msleep(40); } gclose(win);/*つける必要はないですけど開いたら閉じたかったのでつけました*/ return 0; }