1.随笔画

#include <graphics.h>
#include <conio.h>
int main()
{
    initgraph(800,600);   //窗口800*600,白色背景
    setbkcolor(WHITE);    
    cleardevice();        //清屏
    setlinecolor(BLACK);  //黑色实线,5号
    setlinestyle(PS_SOLID, 5);  
    MOUSEMSG m;  //定义鼠标
    
    int a;       //接受坐标
    int b;
    while (true)
    {
        m = GetMouseMsg();             //GetMouseMsg()此函数用于获取鼠标信息,无信息时等待。
        while (m.mkLButton)            //一次存储一条信息,第一次:判断是否按下左键,第二次:获取此时鼠标焦点坐标
        {                              //第三次:判断是否按下左键,若仍为左键则继续内循环,否则退出内循环
            m = GetMouseMsg();         
            a = m.x;
            b = m.y;
            m = GetMouseMsg();
            line(a, b, m.x, m.y);
        }
    }
    
    closegraph();
    system("Pause");
    return 0;
}

2.图形
动手画一下就可以了。

#include <graphics.h>
#include <conio.h>
#include <math.h>
int x[6] = { 0,0,0,0,0,0 };  //正六边形横坐标
int y[6] = { 0,0,0,0,0,0 };  //正六边形纵坐标
int fx[4] = { 0,0,0,0 };     //菱形横坐标
int fy[4] = { 0,0,0,0 };     //菱形纵坐标
double six_edge = 100.0;     //六边形边长
double four_edge = 50.0;      //菱形边长
int main()
{
    initgraph(800, 600);
    setbkcolor(WHITE);
    cleardevice();
    setorigin(400, 300);
    setlinecolor(BLACK);
    setlinestyle(PS_SOLID, 2);
    for (int j = 0; j < 3; j++)
    {
        static double angle = 10;
        for (int i = 0; i < 6; i++)
        {
            x[i] = (int)(six_edge*cos((angle + i * 60.0) / 180.0*3.1415926));
            y[i] = (int)(six_edge*sin((angle + i * 60.0) / 180.0*3.1415926));
        }
        for (int i = 0; i < 5; i++)
        {
            line(x[i], y[i], x[i + 1], y[i + 1]);
            Sleep(200);
        }
        line(x[5], y[5], x[0], y[0]);
        Sleep(200);
        angle += 20.0;  //顺时针旋转20度
    }
    for (int i = 0; i < 18; i++)
    {
        double angle = 20.0; //顺时针旋转20度
        fx[0] = 0; fy[0] = 0;
        fx[1] = fx[0] + (int)(four_edge*cos((90.0 - i * angle) / 180.0*3.1415926));
        fy[1] = fy[0] - (int)(four_edge*sin((90.0 - i * angle) / 180.0*3.1415926));
        fx[2] = fx[1] + (int)(four_edge*cos((30.0 - i * angle) / 180.0*3.1415926));
        fy[2] = fy[1] - (int)(four_edge*sin((30.0 - i * angle) / 180.0*3.1415926));
        fx[3] = fx[2] - (int)(four_edge*cos((90.0 - i * angle) / 180.0*3.1415926));
        fy[3] = fy[2] + (int)(four_edge*sin((90.0 - i * angle) / 180.0*3.1415926));
        for (int j = 0; j < 3; j++)
        {
            line(fx[j], fy[j], fx[j + 1], fy[j + 1]);
            Sleep(200);
        }
        line(fx[3], fy[3], fx[0], fy[0]);
        Sleep(200);
    }
    system("PAUSE");
    closegraph();
    return 0;
}

EasyX程序设计
EasyX程序设计

相关文章:

  • 2021-06-15
  • 2022-12-23
  • 2021-05-02
  • 2021-11-30
  • 2021-11-06
  • 2021-05-11
猜你喜欢
  • 2021-09-24
  • 2021-12-29
  • 2021-08-14
  • 2021-11-28
  • 2021-09-01
  • 2021-12-12
相关资源
相似解决方案