加载中…
个人资料
  • 博客等级:
  • 博客积分:
  • 博客访问:
  • 关注人气:
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

星空(C语言)

(2020-07-28 18:30:49)
标签:

it

教育

分类: 程序
#include "acllib.h"
#include "math.h"
#include“stdio.h”
#include“time.h”
void star(double s, int x, int y)
{
double SR1 = s * sin(72), SR2 = s * sin(54),
CR1 = s * cos(72), CR2 = s * cos(54);
int xA = x, yA = y - s;
int xB = x + CR1, yB = y - SR1;
int xC = x + SR2, yC = y - CR2;
int xD = x - SR2, yD = y - CR2;
int xE = x - CR1, yE = y - SR1;
line(xA, yA, xC, yC);
line(xC, yC, xE, yE);
line(xE, yE, xB, yB);
line(xB, yB, xD, yD);
line(xD, yD, xA, yA);

}
void timer()
{
int i;
beginPaint();
setPenColor(BLACK);
setBrushColor(BLACK);
rectangle(0, 0, 640, 480);
srand((unsigned)time(NULL));
for (i = 0; i < 80;i++)
{
int R = rand() % 255;
int G = rand() % 255;
int B = rand() % 255;
int X = rand() % 640;
int Y = rand() % 480;
setPenColor(RGB(R, G, B));
star(rand() % 30, X, Y);
}
endPaint();
}

int Setup()
{
initWindow("星空", DEFAULT, DEFAULT, 640, 480);


registerTimerEvent(timer);
startTimer(0, 1000);
return 0;
}

星空(C语言)

0

阅读 收藏 喜欢 打印举报/Report
后一篇:纹理(C语言)
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有