现在的位置: 首页 > 综合 > 正文

C语言 绘制漂亮的六叶图案

2014年09月29日 ⁄ 综合 ⁄ 共 719字 ⁄ 字号 评论关闭
#include <graphics.h>
#include <math.h>
#include <conio.h>

#define PI 3.1415926535

/* 图形驱动函数 */
void initgr(void)
{
    int gd = DETECT, gm = 0;
    registerbgidriver(EGAVGA_driver);
    initgraph(&gd, &gm, "");
}

void main(void)
{
    double a = 0, b;
    int x0 = 340, y0 = 240, radius = 100, i, x, y;
    initgr(); /* 驱动图形模式 */
    setcolor(2); /* 设置前景色为绿色 */
    setlinestyle(0, 0, 0); /* 设置股线的类型与宽度 */
    for(i = 0; i < 6; i++, a += 60)
    {
        b = a * PI / 180; /* 把度数转化为弧度 */
        x = x0 + radius * cos(b);
        y = y0 + radius * sin(b);

        arc(x, y, 120 - i * 60, 240 - i * 60, radius); /* 绘制弧线 */
    }
    getch(); /* 暂停屏幕查看结果 */
    closegraph(); /* 关闭图形模式 */
}

—————————————————————————————————

本文原创自Sliencecsdn技术博客。

本博客所有原创文章请以链接形式注明出处。

欢迎关注本技术博客,本博客的文章会不定期更新。

大多数人想要改造这个世界,但却罕有人想改造自己。

世上没有绝望的处境,只有对处境绝望的人。

                                              ————By slience

—————————————————————————————————

抱歉!评论已关闭.