예제 #1
0
int main(int p, char ** q)
{
    //max=atoi(a[0]);
    max = atoi(q[1]);
    int a[100];
    for (int i = 0; i < 100; i++) { a[i] = 0; }
    addpoint(a, 0, 100);
    printf("%d", count);

    for (;;)
	{
		max += 1;
		count = 0;

	    int a[]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,};
    
		addpoint(a, 0, 100);

		time_t t1 = time(0);
		char tmp[64];
        strftime(tmp, sizeof(tmp), "%H_%M_%S", t1);
		printf("%d\t%d\t", max, count); 
		printf(tmp); printf("\n");
		fflush(stdout);

		delete[]a;
	}
}
예제 #2
0
파일: game.cpp 프로젝트: Diodex/Lines
void Game::mousePressEvent(QMouseEvent *pe){
	if(pe->buttons() == 1){
		int x = pe->x()/50;
		int y = (500-pe->y())/50;
		if(arrayofpoints[x][y] != NULL){
			if(activepoint != NULL) activepoint->active = 0;
			activepoint=arrayofpoints[x][y];
			activepoint->active = 1;
		} else {
			if(activepoint != NULL){
			/////////////////////////////////////////	
				if(movepoint(activepoint->x/50,activepoint->y/50,x,y)){
					if(!checkarray()){
						emit scoreChanged();
						addpoint(); addpoint(); addpoint();
					}
					checkarray();
					emit scoreChanged();
				}
			/////////////////////////////////////////
			}
		}

	}

	if(pe->buttons() == 2){
		if(activepoint){
			activepoint->active = 0;
			activepoint = NULL;
		}
	}
}
예제 #3
0
파일: game.cpp 프로젝트: Diodex/Lines
void Game::NewGame(){
	activepoint = NULL;
	for(int i=0; i<10; ++i)
		for(int j=0; j<10; ++j)
			if(arrayofpoints[i][j] != NULL)arrayofpoints[i][j]->del = 1;
	delobjects();
	addpoint();addpoint();addpoint();
	gamescore = 0;
	updatetimer->start(20);
	this->show();	
}
예제 #4
0
int MDraw(double fromx, double fromy, double tox, double toy)
{
    int t = clock();
    int ret = 0;
    {
        int x, y;
        while (g_udlist.pop(&x, &y))
        {
            state& p = pMap[y][x];
            if (p.iter == 0 && p.ed == 0)
            {
                COMPLEX z, c;
                c.re = fromx + (tox - fromx) * (x / (double)BF_W);
                c.im = fromy + (toy - fromy) * (y / (double)BF_H);
                z.re = z.im = 0.0;
                p.c = c;
                p.z = z;
            }
            if (p.ed == 0)
            {
                int k;
                k = MandelbrotEx(p);
                if (p.ed)
                {
                    ret++;
                    {
                        addpoint(x, y-1, k);
                        addpoint(x, y+1, k);
                        addpoint(x-1, y, k);
                        addpoint(x+1, y, k);
                    }
                    g_mi[y][x] = k;
                    /*
                    {
                        color_t c = 0;
                        c = colorMap(p.z, p.iter);
                        putpixel(x, y, c);
                    }// */
                }
                else
                {
                    addpoint(x, y);
                }
            }
            if (kbmouhit()) break;
        }
    }
    g_udlist.swap();
    return ret;
}
예제 #5
0
int main(void)
{
    double dist, sqrt(double);
    struct point *pp, pt, middle, ptmp;
    struct rect screen;

    pt = makepoint(320,240);
    ptmp = makepoint(640,480);
    printf("%d, %d\n", pt.x, pt.y);
    printf("%d, %d\n", ptmp.x, ptmp.y);
    ptmp = addpoint(pt, ptmp);
    pp = &ptmp;
    printf("%d, %d\n", (*pp).x, (*pp).y);
    printf("%d, %d\n", pp->x, pp->y);
    dist = sqrt((double)pt.x * pt.x + (double)pt.y * pt.y);
    printf("%f\n", dist);

    screen = makerect(makepoint(0,0), makepoint(XMAX, YMAX));
    middle = makepoint((screen.pt1.x + screen.pt2.x)/2,
            (screen.pt1.y + screen.pt2.y)/2);
    printf("%d, %d\n", middle.x, middle.y);
    pt = makepoint(2000,2000);
    printf(ptinrect(pt, screen) == 1 ? "point is in rec.\n ":"point is out rect.\n");
    return 0;
}
예제 #6
0
int main()
{
    struct rect screen;
    struct point middle;
    struct point makepoint(int, int);
    screen.pt1 = makepoint(0,0);
    screen.pt2 = makepoint(XMAX, YMAX);
    middle = makepoint((screen.pt1.x + screen.pt2.x)/2,
                       (screen.pt1.y + screen.pt2.y)/2);
    printf("%d %d \n", middle.x, middle.y);

    struct point one = makepoint(1,1);
    printf("%d %d \n", (addpoint(middle, one)).x, (addpoint(middle, one)).y);

    return 0;
}
예제 #7
0
파일: sp_2666.cpp 프로젝트: liuq901/code
void buildtree(int x,int father)
{
   void addpoint(int,int,int);
   int i,z;
   if (s[x]==1)
      return;
   i=b[x];
   z=0;
   while (i!=0)
   {
      if (a[i][0]!=father)
      {                     
         z++;
         p[z][0]=a[i][0];
         p[z][1]=a[i][1];
      }
      i=a[i][2];
   }
   addpoint(x,1,z);
   i=b[x];
   while (i!=0)
   {
      if (a[i][0]!=father)
         buildtree(a[i][0],x);
      i=a[i][2];
   }
}
예제 #8
0
파일: game.cpp 프로젝트: Diodex/Lines
Game::Game(QWidget *pwgt) : QGLWidget(pwgt){
	setGeometry(50,50,500,500);
	srand(time(NULL));
	activepoint = NULL;
	gamescore = 0;

	for(int i=0; i<10; ++i)
		for (int j=0; j<10; ++j) arrayofpoints[i][j] = NULL;

	desk = new Desk;

	updatetimer = new QTimer(this);
	connect(updatetimer, SIGNAL(timeout()), this, SLOT(updateogl()));
	updatetimer->start(20);

	addpoint(); addpoint(); addpoint();
}
예제 #9
0
파일: sp_2666.cpp 프로젝트: liuq901/code
void addpoint(int x,int l,int r)
{
   int mid;
   if (l==r)
   {
      tot++;
      e[tot][0]=x;
      e[tot][1]=p[l][0];
      e[tot][2]=p[l][1];
      return;
   }
   mid=(l+r)/2;
   if (l==mid)
   {
      tot++;
      e[tot][0]=x;
      e[tot][1]=p[l][0];
      e[tot][2]=p[l][1];
   }
   else
   {
      sum++;
      tot++;
      e[tot][0]=x;
      e[tot][1]=sum;
      e[tot][2]=0;
      addpoint(sum,l,mid);
   }
   if (mid+1==r)
   {
      tot++;
      e[tot][0]=x;
      e[tot][1]=p[r][0];
      e[tot][2]=p[r][1];
   }
   else
   {
      sum++;
      tot++;
      e[tot][0]=x;
      e[tot][1]=sum;
      e[tot][2]=0;
      addpoint(sum,mid+1,r);
   }
}
예제 #10
0
main() {
	int i;
	point x, origin = { 0, 0 }, maxpt = { 320, 320 };
	point pts[] = { -1, -1, 1, 1, 20, 300, 500, 400 };
	rect screen = makerect(addpoint(maxpt, makepoint(-10, -10)),
		addpoint(origin, makepoint(10, 10)));

	for (i = 0; i < sizeof pts/sizeof pts[0]; i++) {
		printf("(%d,%d) is ", pts[i].x,
			(x = makepoint(pts[i].x, pts[i].y)).y);
		if (ptinrect(x, screen) == 0)
			printf("not ");
		printf("within [%d,%d; %d,%d]\n", screen.pt1.x, screen.pt1.y,
			screen.pt2.x, screen.pt2.y);
	}
	odd(y);
	return 0;
}
예제 #11
0
int main(){
	struct rect screen;
	struct point middle;

	makepoint(&screen.p1, 0, 0);
	makepoint(&screen.p2, XMAX, YMAX);
	makepoint(&middle, (screen.p1.x + screen.p2.x)/2, (screen.p1.y + screen.p2.y)/2);

	printf("middle : %d, %d\n", middle.x, middle.y);

	addpoint(&screen.p1, &middle);

	printf("screen.py : %d, %d\n", screen.p1.x, screen.p1.y);
}
예제 #12
0
void addpoint(int a[], int m, int n)
{
    int b[100]; for (int i = 0; i < 100; i++) { b[i] = a[i]; }
    b[m] = n;
    if (!check(b, m, n))
    {
        return;
    }
    if (m == max)
    {
        count++;
        return;
    }
    for (int i = 1; i <= max; i++)
    {
        addpoint(b, m + 1, i);
    }
}
예제 #13
0
main()
{
	
	Point pt1 = makepoint(1, 2);
	Point pt2;

	pt2.x = 3;
	pt2.y = 4;
	
	Rect rec;
	rec.pt1 = pt1;
	rec.pt2 = pt2;
	
	printPoint(pt1);
	double sqr = sqrt((double)pt1.x * pt1.x + (double)pt1.y * pt1.y);
	printf("%f\n", dist(pt1));
	printf("%d\n", ptinrect(addpoint(pt1, pt2), rec));
	printf("%d\n", ptinrect(pt1, rec));
}
예제 #14
0
void Widget::receive()
{
    char data[255]; //creation of a char aray
   // int bytesRead = port->read(data, 255); //load the port data
    data[bytesRead] = '\0'; //end the char aray


    //we convert the char into a integer
    int i=0;
    if (bytesRead==1)
    {
        i = data[0];
    }else return; // if the data size is different from 1 => exit the function

    QTextStream out(stdout);
    out << data << " (" << bytesRead << " bytes) understood :" << i<< endl; //writing the data read in the console

    addpoint(i); //we add a point to the graphe

}
예제 #15
0
int main ()
{
	//구조체 정의
	struct rect screen;
	struct point middle;

	screen.pt1 = makepoint (0,0);
	screen.pt2 = makepoint (XMAX, YMAX);
	middle = makepoint ((screen.pt1.x + screen.pt2.x)/2,
					    (screen.pt1.y + screen.pt2.y)/2);

	printf ("middle: %d, %d\n", middle.x, middle.y);

	screen.pt1 = addpoint (screen.pt1, middle);
	printf ("screen.pt1: %d, %d\n", screen.pt1.x, screen.pt1.y);

	printf("\nPress any key to end...");
	getchar(); 
	return 0;
}
예제 #16
0
int main ()
{
	//구조체 정의
	struct rect screen;
	struct point middle;

	//구조체 멤버 연산자(. ->)는 포인터 연산자(& *)보다 우선순위가 높음
	makepoint (&screen.pt1, 0, 0);
	makepoint (&screen.pt2, XMAX, YMAX);
	makepoint (&middle
			  , (screen.pt1.x + screen.pt2.x)/2, (screen.pt1.y + screen.pt2.y)/2);

	printf ("middle: %d, %d\n", middle.x, middle.y);

	addpoint (&screen.pt1, &middle);
	printf ("screen.pt1: %d, %d\n", screen.pt1.x, screen.pt1.y);

	printf("\nPress any key to end...");
	getchar(); 
	return 0;
}
예제 #17
0
파일: 2DContour.cpp 프로젝트: pvaut/Z-Flux
void T2DContourset::generate(TSC_functor *functor, double minv, double maxv, int count)
{
	if (count<2) throw QError(_qstr("Generate contour: invalid number of points"));

	try{
		double vl,vl1,vl2,dff;
		Tvertex pt,pt1,pt2;
		Tvector tangent,norm;
		TSC_funcarglist arglist(NULL);
		TSC_value retval0,arg;
		arg.createtype(GetTSCenv().G_datatype(SC_valname_scalar));
		arglist.add(&arg);
		dff=(maxv-minv)/count/50;
		for (int i=0; i<count; i++)
		{
			vl=minv+(maxv-minv)*i/(count-1.0);
			vl1=vl-dff/2;
			vl2=vl+dff/2;
			arg.copyfrom(vl);functor->eval(&arglist,&retval0);pt=*G_valuecontent<Tvertex>(&retval0);
			arg.copyfrom(vl1);functor->eval(&arglist,&retval0);pt1=*G_valuecontent<Tvertex>(&retval0);
			arg.copyfrom(vl2);functor->eval(&arglist,&retval0);pt2=*G_valuecontent<Tvertex>(&retval0);
			tangent.subtr(&pt2,&pt1);
			norm.vecprod(&tangent,&Tvector(0,0,1));norm.normfrom(&norm);
			addpoint(&pt,&norm);
		}
	}
	catch(TSC_runerror err)
	{
		QString errstring;
		FormatString(errstring,_text("Generate contour: ^1"),err.G_content());
		throw QError(errstring);
	}
	catch(QError err)
	{
		QString errstring;
		FormatString(errstring,_text("Generate contour: ^1"),err.G_content());
		throw QError(errstring);
	}
}
예제 #18
0
void tut1(){
	struct rect screen;
	struct point middle;
	struct point makepoint(int, int);

	screen.pt1 = makepoint(0, 0);
	screen.pt2 = makepoint(XMAX, YMAX);
	middle = makepoint((screen.pt1.x + screen.pt2.x)/2, (screen.pt1.y + screen.pt2.y)/2);

	struct point pt1 = makepoint(10, 10);
	struct point pt2 = makepoint(20, 20);

	struct point tst = addpoint(pt1, pt2);

	printf("pt1~ x: %d | y: %d\n", pt1.x, pt1.y);
	printf("pt2~ x: %d | y: %d\n", pt2.x, pt2.y);
	printf("tst~ x: %d | y: %d\n", tst.x, tst.y);

	struct point origin,  *pp;
	origin = makepoint(0, 0);
	pp = &origin;
	printf("origin is (%d,%d)\n", pp->x, pp->y);

}
예제 #19
0
void readobj(FILE *input)
{
	char buffer[256];
	int index_a_vertex, index_a_texture, index_b_vertex, index_b_texture, index_c_vertex, index_c_texture;
	int ignored_a_normal, ignored_b_normal, ignored_c_normal;
	float u, v;
	float x, y, z;
	bool normalsDetected = false;

	if (input == NULL)
	{
		return;
	}

	points = NULL;
	count_points = 0;

	uvcoords = NULL;
	count_uvcoords = 0;

	faces = NULL;
	count_faces = 0;

	while (fgets(buffer, 256, input) != NULL)
	{
		if (buffer[0] == 'v' && buffer[1] == 'n')
		{
			normalsDetected = true;
		}
		else if (buffer[0] == 'v' && buffer[1] == 't')
		{
			sscanf(&buffer[3], "%f %f", &u, &v);
			if (invertV)
				v = 1.0f - v;
			adduvcoord(u,v);
		}
		else if (buffer[0] == 'v')		// && buffer[1] != 't' && buffer[1] != 'n'
		{
			sscanf(&buffer[2], "%f %f %f", &x, &y, &z);
			addpoint(x*scaleFactor,
					 (swapYZ?z:y)*scaleFactor,
					 (swapYZ?y:z)*scaleFactor);
		}
		else if (buffer[0] == 'f' )
		{
			if(normalsDetected)
			{
				sscanf(&buffer[2], "%d/%d/%d %d/%d/%d %d/%d/%d",
					   &index_a_vertex, &index_a_texture, &ignored_a_normal,
					   &index_b_vertex, &index_b_texture, &ignored_b_normal,
					   &index_c_vertex, &index_c_texture, &ignored_c_normal);
			}
			else
			{
				sscanf(&buffer[2], "%d/%d %d/%d %d/%d",
					   &index_a_vertex, &index_a_texture,
					   &index_b_vertex, &index_b_texture,
					   &index_c_vertex, &index_c_texture);
			}

			if(reverseWinding || twoSided)
			{
				addface(index_c_vertex - 1, index_c_texture - 1,
						index_b_vertex - 1, index_b_texture - 1,
						index_a_vertex - 1, index_a_texture - 1);
			}
			if(!reverseWinding || twoSided)
			{
				addface(index_a_vertex - 1, index_a_texture - 1,
						index_b_vertex - 1, index_b_texture - 1,
						index_c_vertex - 1, index_c_texture - 1);
			}
		}
	}
}
예제 #20
0
/////////////////////////////////////////////////
// 主函数
/////////////////////////////////////////////////
int main(int argc, char* argv[])
{
    // 初始化绘图窗口及颜色
    setinitmode(0x005, 0, 0);
    if (argc < 2)
    {
        MessageBoxW(NULL, L"本屏幕保护程序无配置", L"JuliaSet", MB_OK);
        return 0;
    }
    else if (stricmp(argv[1], "/p") == 0)
    {
        HWND hwnd;
        sscanf(argv[2], "%d", &hwnd);
        attachHWND(hwnd);
        setinitmode(0x107, 0, 0);
    }
    else if (stricmp(argv[1], "/s"))
    {
        MessageBoxW(NULL, L"本屏幕保护程序无配置", L"JuliaSet", MB_OK);
        return 0;
    }

    //initgraph(320, 240);
    initgraph(-1, -1);

    randomize();
    showmouse(0);
    FlushMouseMsgBuffer();
    while(kbhit()) getch();

    //InitColor();
    InitLog();
    g_w = getwidth(NULL);
    g_h = getheight(NULL);
    g_st = (state*)malloc(g_w * g_h * sizeof(state));
    COMPLEX c = {0.262, 0.002}, z = {0, 0};
    double r = 1.5, d = g_w / (double)g_h, rotate = 0, sr = sin(rotate), cr = cos(rotate);
    init_st(g_w, g_h);
    int n_update = 0;
    double ftime = fclock();
    {
        double dc = 64, dca = 128, db = 16;
        col_r = randomf() * dc + db;
        col_g = randomf() * dc + db;
        col_b = randomf() * dc + db;
        col_ar = randomf() * dca;
        col_ag = randomf() * dca;
        col_ab = randomf() * dca;
        rotate = randomf() * 360;
        sr = sin(rotate), cr = cos(rotate);
    }
    setrendermode(RENDER_MANUAL);
    for (int loop = 1; kbmouhit() == 0; ++loop)
    {
        int ret;
        if (loop <= 4)
        {
            ret = JDraw(c, z.re - r * d, z.im - r, z.re + r * d, z.im + r, sr, cr);
            if (loop == 4)
            {
                g_udlist.swap();
                for(int y=0; y<g_h; y++)
                {
                    for(int x=0; x<g_w; x++)
                    {
                        if (g_st[y * g_w + x].ed == 0)
                        {
                            g_udlist.push(x, y);
                        }
                    }
                }
                g_udlist.swap();
            }
        }
        else
        {
            static int t = 0;
            ret = JDrawA(c, z.re - r * d, z.im - r, z.re + r * d, z.im + r);
            if (clock() - t > 30)
            {
                delay(1);
                t = clock();
            }
        }
        if (g_updatepoint == 0)
        {
            n_update++;
        }
        else
        {
            n_update = 0;
        }
        if (0)
        {
            char str[500];
            sprintf(str, "%d %d %f %f", g_w, g_h, r, d);
            outtextxy(0, 0, str);
        }
        if (ret == 0 || n_update > 8 || loop > 1000)
        {
            loop = 0;
            if (g_mi[0][0] == 0)
            {
                delay(1);
                memset(pMap, 0, BF_W * BF_H * sizeof(state));
                g_udlist.clear();
                for (int i = 0; i < BF_W; ++i)
                {
                    addpoint(i, 0);
                    addpoint(i, BF_H - 1);
                }
                for (int i = 0; i < 4; )
                {
                    if (MDraw(-1.9, -1.2, 0.5, 1.2) == 0)
                    {
                        ++i;
                    }
                    else
                    {
                        i = 0;
                    }
                    if (kbmouhit()) return 0;
                }
            }
            double dc = 64, dca = 128, db = 16;
            col_r = randomf() * dc + db;
            col_g = randomf() * dc + db;
            col_b = randomf() * dc + db;
            col_ar = randomf() * dca;
            col_ag = randomf() * dca;
            col_ab = randomf() * dca;
            rotate = randomf() * 360;
            sr = sin(rotate), cr = cos(rotate);
            do
            {
                c.re = randomf() * 2.4 - 1.9;
                c.im = randomf() * 2.4 - 1.2;
                int ir = (int)((c.re - (-1.9)) / (0.5 - (-1.9)) * BF_W);
                int im = (int)((c.im - (-1.2)) / (1.2 - (-1.2)) * BF_H);
                if (g_mi[im][ir] >= 16)
                {
                    break;
                }
            } while (1);
            init_st(g_w, g_h);
            n_update = 0;
            if (fclock() - ftime < 3)
            {
                delay_ms((int)((3 - (fclock() - ftime)) * 1000));
            }
            else
            {
                delay(1);
            }
            ftime = fclock();
        }
    }

    closegraph();
    return 0;
}