コード例 #1
1
ファイル: hanzi.c プロジェクト: michaelhou/42
void main()
{
	//before
	int ret;
	ret=initwindow();	//check error!!!!!

	//unicode
	ret=initunicode(0x04000400,palette);

	//forever
	QWORD type=0;
	QWORD key=0;
	while(1)
	{
		//1.先在内存里画画,然后一次性写到窗口内
		printworld();
		writewindow(0x04000400,palette);

		//2.等事件,是退出消息就退出
		uievent(&type,&key);
		if( type==0 )break;
		if( (type==0x64626b)&&(key==0x1b))break;


		//3.处理事件,如果要求自杀就让它死
		processmessage(type,key);
	}

	//after
death:
	killwindow();
}
コード例 #2
0
// Гонки
main()
{ 
  int y=100;              // описание переменной и одновременно задание начального значения
  int y1=300;
  int x= 70;
  int x1= x;
  int y2=500;
  int x2= x;
  srand (time (NULL));   // устанавливаем случайное начало для ряда случайных числе
  initwindow(800,600,"Gonky"); // открыть окно для графики размером 800 на 600 пикселей
  do
  {
   setfillstyle(1,GREEN);   // цвет закраски - зеленый
   circle(x,y,50);
   floodfill(x,y,WHITE);
   
   setfillstyle(1,RED);
   circle(x1,y1,50);         // цвет закраски - красным
   floodfill(x1,y1,WHITE);
   
   setfillstyle(1,YELLOW);
   circle(x2,y2,50);         // цвет закраски - желтым
   floodfill(x2,y2,WHITE);
   
   delay(10);                   
   setfillstyle(1,BLACK);   // затираем оба кружка
   floodfill(x,y,BLACK);
   floodfill(x1,y1,BLACK);
   floodfill(x2,y2,BLACK);
   
   x=x+rand()%15;           // шаг случайный
   x1=x1+rand()%15;
   x2=x2+rand()%15;
  }
  while (x<=760 && x1<=760); // пока не достигнут края окна
   if (x1>x and x1>x2) initwindow(800,600,"Victory RED!!!");  // выводим в заголовке окна текст
       else 
        if (x>x1 and x>x2) initwindow(800,600,"Victory GREEN!!!");
            else initwindow(800,600,"Victory YELLOW!!!");
   setfillstyle(1,GREEN);   // рисуем окончательный вариант расположения кружков
   circle(x,y,50);
   floodfill(x,y,WHITE);
   setfillstyle(1,RED);
   circle(x1,y1,50);         
   floodfill(x1,y1,WHITE);
   getch();
   closegraph();
}
コード例 #3
0
ファイル: putpixel.c プロジェクト: lucasteles/Fundations
int main( )
{
    int largura = 640;
    int altura = 480;
    
    int x,y,r,g,b = 0;
    
    initwindow(largura, altura);    
        
    
    
    int counter = 0;
    
    
    outtextxy(50,50, "Demonstracao da funcao putpixel");
    
    while (!kbhit( ))
    {
      
        x = rand()%largura;
        y = rand()%altura;
        r = rand()%255;
        g = rand()%255;
        b = rand()%255;       
                 
        putpixel(x,y, COLOR(r,g,b));
        
    }
    return 0;
}
コード例 #4
0
int main()
{
    int x1,x2,y1,y2,dx,dy;
    float len,new_dx,new_dy,x,y;
    printf("Enter the x1,y1 Value");
    scanf("%d%d",&x1,&y1);
    printf("Enter the x2,y2 Value");
    scanf("%d%d",&x2,&y2);
    initwindow(600,800);
    dx=x2-x1;
    dy=y2-y1;
    if(abs(dx)>=abs(dy))
    {
       len=abs(dx);
       }
    else
    {
        len=abs(dy);
        }
    new_dx=dx/len;
    new_dy=dy/len;
    x=x1+0.5*(new_dx);
    y=y1+0.5*(new_dy);
    int i=1;
    while(i<=len)
    {
    putpixel(int(x),int(y),RED);
    x+=new_dx;
    y+=new_dy;
    i=i+1;
}
 while(!kbhit()); 
closegraph(); 
}
コード例 #5
0
ファイル: main.cpp プロジェクト: 20anya02/osminozhka
int main(){
	int k,c;
	int exitOk=0;
	int tmp;

	initwindow(1000, 600);
	settextstyle(2,0,25);
	Start();
	DrawField();

	while(!exitOk){
		c=getch();
		switch(c){
			case 27: exitOk=1;
			case 75: if(cur_i<3) {cells[cur_j][cur_i]=cells[cur_j][cur_i+1]; cells[cur_j][cur_i+1]=0; cur_i++;} break;
			case 77: if(cur_i>0) {cells[cur_j][cur_i]=cells[cur_j][cur_i-1]; cells[cur_j][cur_i-1]=0; cur_i--;}  break;
			case 72: if(cur_j<3) {cells[cur_j][cur_i]=cells[cur_j+1][cur_i]; cells[cur_j+1][cur_i]=0; cur_j++;}  break;
			case 80: if(cur_j>0) {cells[cur_j][cur_i]=cells[cur_j-1][cur_i]; cells[cur_j-1][cur_i]=0; cur_j--;}  break;
			default: break;
		}
		DrawField();
	}
	closegraph();
	return 0;
}
コード例 #6
0
int main()
{
    int x1,y1,x2,y2,dx,dy,i;
    float p;
    initwindow(800,600);
    printf("enter x1,y1");
    scanf("%d%d",&x1,&y1);
    printf("enter x2,y2");
    scanf("%d%d",&x2,&y2);
    putpixel(x1,y1,WHITE);
    dx=x2-x1;
    dy=y2-y1;
    p=2*dy-dx;
    for(i=0; i<=dx; i++)
    {
        if(p>0)
        {
            x1+=1;
            putpixel(x1,y1,WHITE);
            p+=2*dy;
        }
        else
        {
            x1+=1;
            y1+=1;
            putpixel(x1,y1,WHITE);
            p+=(2*dy)-(2*dx);
        }
    }
    while(!kbhit());
    closegraph();
}
コード例 #7
0
ファイル: 03.29.c プロジェクト: NoMan2000/c-prog
 int
 main(void)
 {
initwindow(640, 500, "House - press a key to close", 100, 50);

 /* Define corners of house */
 int x1 = 100; int y1 = 200; /* top-left corner */
 int x2 = 300; int y2 = 100; /* roof peak */
 int x3 = 500; int y3 = 200; /* top-right corner */
 int x4 = 500; int y4 = 400; /* bottom-right corner */
 int x5 = 325; int y5 = 400; /* bottom-right corner of door */
 int x6 = 275; int y6 = 325; /* top-left corner of door */

 /* Draw roof. */
 line(x1, y1, x2, y2); /* Draw line from (x1, y1) to (x2, y2) */
 line(x2, y2, x3, y3); /* Draw line from (x2, y2) to (x3, y3) */

 /* Draw rest of house. */
 rectangle(x1, y1, x4, y4);

 /* Draw door. */
 rectangle(x5, y5, x6, y6);

 getch(); /* pause until user presses a key */
 closegraph(); /* close the window */

 return(0);
}
コード例 #8
0
ファイル: main.cpp プロジェクト: DSG888/SibSUTIS
void grafik(int m) {
    initwindow(400, 300);
    moveto(200, 0);
    lineto(200, 400);
    moveto(200, 0);
    lineto(198, 5);
    moveto(200, 23,56);
    lineto(202, 5);
    moveto(0, 200);
    lineto(400, 200);
    lineto(395, 202);
    moveto(400, 200);
    lineto(395, 198);
    outtextxy(390, 203, "x");
    outtextxy(187, 0, "y");
    int l;
    double xg, yg;
    for (xg = -200; xg < 200; xg+=0.01) {
        yg = pow(xg, 0.5);
        putpixel(200+xg*m, 200-yg*m, 4);
    }
    for (l = 0; l < n; l++) {
        setcolor(10);
        circle(200+x[l]*m, 200-y[l]*m, 3);
    }
    for (xg = -200; xg < 200; xg+=0.01) {
        yg = lagr(xg);
        putpixel(200+xg*m, 200-yg*m, 2);
    }
}
コード例 #9
0
ファイル: bgidemo3.cpp プロジェクト: Skovpin/CodeBlocks-RG
void main(void)
{
    int loopCounterx,loopCountery,inputChar,i,j;
    void *myImage1,*myImage2;

    // Put the machine into graphics mode and set the maximum coordinates:
    initwindow(600, 400);

    for (loopCounterx=0;loopCounterx<600;loopCounterx+=20)
    	for (loopCountery=0;loopCountery<200;loopCountery+=20)
	{
	    setfillstyle(SOLID_FILL, COLOR(255*loopCounterx/600, 255*loopCountery/200, 0));
	    bar(loopCounterx , loopCountery, loopCounterx+20, loopCountery+20);
	}
    
    for (loopCounterx=0;loopCounterx<600;loopCounterx+=20)
    	for (loopCountery=200;loopCountery<400;loopCountery+=20)
	{
	    setfillstyle(SOLID_FILL, COLOR(0, 255*loopCounterx/600, 255*(loopCountery-200)/200));
	    bar(loopCounterx , loopCountery, loopCounterx+20, loopCountery+20);
	}

    cout << "Press return in the graphics window to end program." << endl;
    getch( );
    
    // Switch back to text mode:
    closegraph( );
}
コード例 #10
0
Graph::Graph(char* data_file, char* x_label, char* y_label){

    this->data_file = data_file;
    this->x_label = x_label;
    this->y_label = y_label;

    counter = 0; // No of points to be plotted, set in constructor.

    FILE *file = fopen(data_file , "r");
    buff = (char*) malloc(255);

    // status reads the number of strings converted by fscanf
    // flip keeps track of 0, 1 position in the array
    char status;
    bool flip = 0;

    do {
        status = fscanf(file, "%s", buff);
        points[counter][flip] = atoi(buff);
        if(flip == 1){
            ++counter;
        }
        flip = !flip;
    }while(status == 1);

    initwindow(MAX_X, MAX_Y, "Asif & Sameem's plots."); // Looks better with my name first ;)
    init();
}
コード例 #11
0
ファイル: curs.cpp プロジェクト: BorisBochkaryov/Battleship
int main(){
    setlocale(LC_ALL, "Russian");     
    initwindow(700,400);  
    Start();
    closegraph();
    return 0;
}
コード例 #12
0
ファイル: dblbuff.cpp プロジェクト: Skovpin/CodeBlocks-RG
int main( )
{
    const int COLUMNS = 8;
    const int ROWS = 16;

    int x, y;        // x and y pixel locations
    int row, column; // Row and column number
    int box_width;   // Width of a color box in pixels
    int box_height;  // Height of a color box in pixels
    int color;       // Color number, now ranging from 0 to 127

    // Initialize the graphics window and set the box size.
    initwindow(400,300);
    box_width = getmaxx( ) / COLUMNS;
    box_height = getmaxy( ) / ROWS;

    // Draw some items on pages 1 and 0:
    setactivepage(1);
    line(0, 0, getmaxx( ), getmaxy( ));
    outtextxy(100, 100, "This is page #1.");
    outtextxy(100, 120, "Press a key to end the program.");
    setactivepage(0);
    line(getmaxx( ), 0, 0, getmaxy( ));
    outtextxy(100, 100, "This is page #0.");
    outtextxy(100, 120, "Press a key to see page #1.");

    // Get the user to press a key to move to page 1:
    getch( );
    setvisualpage(1);
    getch( );

}
コード例 #13
0
main()
{
  initwindow (800, 600);                 // ¬ключить графику и создать окно 
  forest(100);
  getch();
  closegraph();
}
コード例 #14
0
ファイル: Bill.cpp プロジェクト: carriercomm/BillingSystem-6
int main()
{
      
  initwindow(1000,700);
  top:
  int x(0),y(0);
  
  while (!ismouseclick(WM_LBUTTONDOWN))
        {
            setfillstyle(SOLID_FILL, RED);
            rectangle(0,0,1000,700);
            floodfill(0,0,RED);
            readimagefile("logo.bmp",0,0,80,80);
            settextstyle(9,HORIZ_DIR,6);
            setbkcolor(WHITE);
            setcolor(BLACK);
            outtextxy(400,10,"BILL");
            settextstyle(9,HORIZ_DIR,3);
            outtextxy(20,100,"Particulars");
            outtextxy(300,100,"Qty");
            outtextxy(500,100,"Rate(in Rs.)");
            outtextxy(800,100,"Amount");
            //if qty is >0,print the item name ......etc
            
        }   
}
コード例 #15
0
ファイル: Lab6.cpp プロジェクト: tanvir002700/Assignment
int main()
{
    int winW=500;
    int winH=500;

    printf("\nProvide view port coordinate(0 to 500) : ");
    scanf("%d %d %d %d", &vx1, &vy1, &vx2, &vy2);

    initwindow(winW,winH,"test");

    drawLine(vx1,vy1, vx2, vy1);
    drawLine(vx2,vy1, vx2, vy2);
    drawLine(vx2,vy2, vx1, vy2);
    drawLine(vx1,vy2, vx1, vy1);


    while(1){
    printf("\nProvide line coordinate (0 to 500): ");
    scanf("%d %d %d %d", &lx1, &ly1, &lx2, &ly2);
    clip(lx1, ly1, lx2, ly2);
    }

    getch();
    closegraph();

    return 0;
}
コード例 #16
0
ファイル: EX02.cpp プロジェクト: Tydenius/Prog-2---N1
int main () 
{
 initwindow(800, 600, "Ex 02");
	while (!kbhit())
	{	
		if (pg == 1) pg = 2; else pg = 1;
		setactivepage(pg);		//pagina ativa
		cleardevice();			//limpa tela
		desenhaCampo();
		if(i <= 510){			//desenha fundo
			desenhaBarco(); 	//desenha barco
		}else{
			viraBarco();
			if(vira == 0){			 //desenha barco na horizontal
			 j++;
			 if(barco[6] == 800){
			 	vira = 1;
			 }
			}else{
			 j--;
			 if(barco[0] == 0){
			 	vira = 0;
			 }
			}
		}			
		setvisualpage(pg);		//pagina mostrada ao usuário
	}
	
 getch();
}
//-------------------------------------------------------------------------------
void initializations(void)
{
initreferences();
initmatrices();
initbuffer();
initScrambler();
initTwindleMatrix();
initwindow();
initfilter();
}
コード例 #18
0
//Beginning of initGraphics proceedure. This initializes the graphics window and the arrays used in graphical operations
void initGraphics(struct graphicWindow*dimenPtr, soil_palette*soilPalette)
{
	//Draws graphics window, based on X range in pixels(+200px border for legend) and Y range in px
	initwindow((int)dimenPtr->rangeXScale + 200, (int)dimenPtr->rangeYScale);
	resetWindow();
	drawText("Enter a depth in the console to see the soil info. at that depth.");
	initSoilClr(soilPalette);
	initSoilStr(soilPalette);
	initSoilType(soilPalette);
}
コード例 #19
0
ファイル: malla.cpp プロジェクト: miguellgt/Game-YoRobot
int main()
{
    initwindow( 1358, 700 ); //open a 400x300 graphics window
    
    dibujaMenu();
    malla();
    
    getch();
    closegraph();        //close graphics window
}
コード例 #20
0
ファイル: su.c プロジェクト: ragilr/sudoku-solver
int main()
{
    initwindow(600,600,"SU-DO-KU");
    readsudoku();
    print_ans();
    fill(a,ans,BLACK);
    printf("\nThe Solved Su-do-ku:\n");
    solve_sudoku(0);
    getch();
}
コード例 #21
0
ファイル: scanline_fill.c プロジェクト: viren-nadkarni/codu
int main()
{
initwindow(320,240);
rectangle(32, 24, 188, 216);
circle(160, 120, 29);
scanline(50, 40, BLUE, WHITE);
while(!kbhit())
delay(50);
return EXIT_SUCCESS;
}
コード例 #22
0
main()
{
    initwindow (400, 300,"Triangles");
    Tr (100, 100, COLOR(0,0,255));
    Tr (200, 220, COLOR(0,255,0));
    Tr (200, 160, COLOR(255,0,0));
    Tr (100, 220, COLOR(0,255,0));
    Tr (100, 160, COLOR(0,0,255));
    getch();
    closegraph();
}
コード例 #23
0
ファイル: bresanham.cpp プロジェクト: viren-nadkarni/codu
int main()
{
	initwindow(640, 360, "DDA - railway");
	
	b_line(12,12,300,300);
	
	while ( !kbhit() )
		delay(100);

	return EXIT_SUCCESS;
}
コード例 #24
0
void top()
{
     initwindow(1275,700);
     setfillstyle(1,1);
     floodfill(100,100,1);
     setcolor(12);
     setbkcolor(BLUE);
     settextstyle(0,0,2);
     outtextxy(925,670,"Press any key to go back");
     
}
コード例 #25
0
ファイル: 1-st.cpp プロジェクト: DSG888/SibSUTIS
main() {
    initwindow(800,600); // инициализируем графическое окно
    tpoint *pt[200]; // массив для 200 точек
    for (int i=0;i<200;i++) {
        pt[i]=new tpoint(800,600); // инициализируем кажду точку (вызываем для каздой конструктор)
    }
    while (1) { // бесконечный цикл
          for (int i=0;i<200;i++)
              pt[i]->move(); // двигаем каждую точку
    }
    closegraph(); // закрываем графическое окно
}
コード例 #26
0
ファイル: main.cpp プロジェクト: shsty/SDL-GLSL-test
int main(int argc, char *argv[]){
    SDL_Window * window;
    SDL_GLContext context;

    initwindow(&window, &context);

    drawscene(window);

    destroywindow(window, context);

    return 0;
}
コード例 #27
0
int main(int argc, char * argv[])
{
initwindow(400,400,"window");
ellipsemidpoint(100,100,80,50);
ellipsemidpoint(100,80,40,20);
//tyres
ellipsemidpoint(25,130,30,30);
ellipsemidpoint(175,130,30,30);
while(!kbhit())
delay(50);
return EXIT_SUCCESS;
}
コード例 #28
0
ファイル: BoundaryFill4.c プロジェクト: moon2222/my_programs
int main()
{
    int gd=DETECT,gm,min=0,maximum=0,c, location,loc, pp,  o,m,counter=0,ix,iy,BC,IC,FC;
    int p[100];
	int color=2;
    double t,m1;
    DWORD dwWidth = GetSystemMetrics(SM_CXSCREEN);
    DWORD dwHeight = GetSystemMetrics(SM_CYSCREEN);
    initwindow(dwWidth,dwHeight);
    int x0=dwWidth/2;
    int y0=dwHeight/2;
    int i,j,x[50],y[50];
    double xc[50],yc[50];

    for(i=0; i<dwHeight; i++)
        putpixel(x0,i,RED);

    for(j=0; j<dwWidth; j++)
        putpixel(j,y0,RED);

    int n;
    printf("Enter the number of coordinates or vertices \n");
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        printf("Enter the %dth coordinate\n",i+1);
        scanf("%d",&x[i]);
        scanf("%d",&y[i]);
    }
    for(i=0;i<n;i++)
        printf("%d\t%d\n",x[i],y[i]);
    while(z!=(n-1))
    {
        line_draw(x[z],y[z],x[z+1],y[z+1],x0,y0,color);
        z++;
    }



    //Here
    printf("Enter interior cordinates ix and iy and fill colour \n");
    scanf("%d%d%d",&ix,&iy,&IC);
    boundaryfill4(x0+ix,y0-iy,IC);

    delay(40000);


    cleardevice();
    closegraph();

}
コード例 #29
0
void createWindow(char* windowName, int boardSize, MouseListener l) {
    int windowSize = 2*BOARD_PADDING + boardSize * TILE_SIZE;
    initwindow(windowSize, windowSize, windowName);
    setbkcolor(LIGHTGRAY);
    clearScreen();
    swapBuffers();

    mouseClickListener.l = l;

    // register mouse listeners
    registermousehandler(WM_LBUTTONDOWN, mouseDown);
    registermousehandler(WM_LBUTTONUP, mouseUp);
    registermousehandler(WM_MOUSEMOVE, mouseMove);
}
コード例 #30
0
ファイル: ty.cpp プロジェクト: Saurabha94/The-V-Play-Store
void thank()
{
    closegraph();
    initwindow(1275,700);
    setfillstyle(1,1);
    floodfill(1,1,1);
    settextstyle(1,0,7);
    setcolor(10);
    setbkcolor(1);
    outtextxy(70,250,"Thankyou for the Purchase");
    delay(3000);
    home();
    recommend(10,11);
}