Full tutorial on how to use VC6.0+Graphics graphics library to draw two-dimensional graphics

The first is to install VC6.0. There are many versions on the Internet, which are uneven. Here is a very useful VC6.0 (extraction code: 1bn9)

Does not support win10,8, if you have to use it, please use a virtual machine or reinstall win7 system

Just follow the prompts to install it. If it doesn’t work, install it several times (if the c drive fails, install the d drive). There is nothing special to configure.

Then it's about the Graphics graphics library. This is simpler and also has script software, which can be installed and used directly. Remember to restart after installing VC6.0

The executable software is: EasyX (extract code: 9v9w)

There will be a prompt after the installation is completed and opened directly. You can click to automatically add the Graphics graphics library. If not, install it manually. There is an EasyX_help document in it, which is written in great detail. Just follow the prompts inside.

After the installation is complete, open VC6.0

Click File, select New, click Project in the New window, select the new project win32 Application, enter the project name, and click OK

 

The following window appears:

It is recommended to directly click on a blank project, select Next, and complete

Then the following window appears, click Source Files, then click the file in the upper left corner, select the first New, select C++ Source Flie, enter the file name, and click OK

In the blank file that appears, copy the following code into it:

#include <graphics.h>       // You need to reference this graphics library 
#include <conio.h>  
#include <iostream> 
#include <math.h>
 using  namespace std;
 #define PI 3.1415926
 int ix= 300 ,iy= 300 ; // The center point around the circle 
double tx,ty;
 void change( int x, int y, double angle){
     int length=x-ix+y-iy; // rotation axis length 
    tx=(x-ix)*cos (angle)-(y-iy)*sin(angle)+ix; //x0= (x - rx0)*cos(a) - (y - ry0)*sin(a) + rx0 ;angle means clockwise rotation, -angle means counterclockwise rotation 
    ty=(x-ix)*sin(angle) +(y-iy)*cos(angle)+iy; // y0= (x - rx0)*sin(a) + (y - ry0)*cos(a) + ry0 ; 
}
 void main()
{    
    initgraph( 640 , 640 );    // slightly different from TC here 
    int n= 20 ; // n represents how many times it has been rotated 
    int a= 200 ,b= 200 ,c= 300 ,d= 300 ; // four rectangles The points are (200,200),(200,300),(300,300),(300,200) 
    double perangle= 2 *PI/ n;
     // cout<<"PI= "<<PI<<" perangle= "<<perangle<< " cos(perangle)= "<<cos(perangle)<<" cos(PI)="<<cos(PI*90/180); 
    for ( int i= 1 ;i<=n;i++ ){
        change(a,b,i*perangle);
        moveto(tx,ty);
        int ia = tx, ib = ty;
        change(a,c,i*perangle);
        lineto (tx, ty);
        change(d,c,i*perangle);
        lineto (tx, ty);
        change(d,b,i*perangle);
        lineto (tx, ty);
        lineto (ia, ib);
    }
    getch();                // Press any key to continue     
    closegraph();           // Close the graphical interface 

}

Click on the exclamation mark below

If the following result appears, congratulations, you have completed the first Graphics graphic demo

 

 

 

 

If there is a problem, please try several times, most of it is because the header file is not imported successfully, don't rush it slowly, try again step by step

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325887816&siteId=291194637