void test(){ //创建 psnum个点; ps = malloc(psNum * sizeof(struct Point)); for(int i = 0;i<psNum;i++){ reSet(&(ps[i])); printf("i:%d ps[i].speed:%f\n",i,ps[i].speed); } }
void run(){ system("clear"); struct winsize win; ioctl(STDOUT_FILENO,TIOCGWINSZ,&win); w = win.ws_col; h = win.ws_row -3; //动态分配绘图区的二维数组 img = malloc (h * sizeof(char *)); for(int iw = 0; iw< h;iw++){ img[iw] = malloc(w*sizeof(char)); } p1.x= 10.0; p1.y = 10.0; p1.view = '@'; p1.rad = 3.14; reSet(&p1); //创建100个点 ps = malloc(psNum * sizeof(struct Point)); for(int i = 0;i<psNum;i++){ reSet(&(ps[i])); printf("i:%d ps[i].speed:%f\n",i,ps[i].speed); } char s[] = "---gcc test---- "; setLog(s,sizeof(s)-1); draw(); paint(); while(1){ updata(); usleep(dt); } }
void shapeSetting::initConnect() { connect(drawArea, SIGNAL(sendPoint(float, float)), this, SLOT(addItem(float, float))); connect(drawArea, SIGNAL(finished(bool)), this, SLOT(available(bool))); //connect(apply, SIGNAL(clicked()), this, SLOT(createShape())); connect(cancel, SIGNAL(clicked()), this, SLOT(clear())); connect(reset, SIGNAL(clicked()), this, SLOT(reSet())); connect(pc, SIGNAL(valueChanged(double)), this, SLOT(valueChanged())); connect(scale, SIGNAL(valueChanged(double)), this, SLOT(valueChanged())); //connect(this, SIGNAL(valueChanged()), this, SLOT(enableReset())); }
//一个点移动 void move(struct Point *p){ double vy =( p -> speed ) * sin( p -> rad) /2; double vx =( p-> speed ) * cos( p -> rad); double sx = vx * dt/1000000.0; double sy = vy * dt/1000000.0; p ->x = p -> x + sx; p-> y = p -> y + sy; lvx =p->x; lvy = p->y; tempD = dt/1000000; if( (p->x) > 2 && (p->x) < w-2 & (p->y) > 2 && (p->y) < h-2 ){ }else{ reSet( p); } ti = ti+1; img[(int)(p->y)][(int)(p->x)] = p->view; }