zoukankan      html  css  js  c++  java
  • 绘制五角星

    #include <graphics.h>
    #include <math.h>
    main()
    {
        int i, j = 0, gdriver, gmode, points[20];
        gdriver = DETECT;
        initgraph(&gdriver, &gmode, "");        /*图形方式初始化*/
        setcolor(YELLOW);          /*设置绘图颜色*/
        setlinestyle(0, 0, 1);          /*设置线形*/
        for (i = 0; i < 5; i++)
        {
            points[j++] = (int)(320+150 * cos(0.4 *3.1415926 * i));   /*五角星外圈点的横坐标存入数组中*/
            points[j++] = (int)(240-150 * sin(0.4 *3.1415926 * i));   /*五角星外圈点的纵坐标存入数组中*/
            points[j++] = (int)(320+50 * cos(0.4 *3.1415926 * i + 0.6283));  /*五角星内圈点的横坐标存入数组中*/
            points[j++] = (int)(240-50 * sin(0.4 *3.1415926 * i + 0.6283));  /*五角星内圈点的纵坐标存入数组中*/
        }
        setfillstyle(1, RED);          /*设置填充方式*/
        fillpoly(10, points);          /*对五角星进行填充*/
        getch();
        closegraph();           /*退出图形状态*/
    }
  • 相关阅读:
    补码原理
    清风徐来,水波不兴
    月尾和周尾
    又一春又一季
    9.11
    晨光无限
    9.18
    心悠
    小事一桩
    一周岁啦
  • 原文地址:https://www.cnblogs.com/djcsch2001/p/1960115.html
Copyright © 2011-2022 走看看