c语言玫瑰花代码直接复制
时间: 2023-11-16 22:07:35 浏览: 4393
这是一个c语言的玫瑰花表白代码,可以直接复制使用:
#include <graphics.h>
#include <conio.h>
#include <math.h>
int rosesize = 500;
int h = -250;
struct DOT {
double x;
double y;
double z;
double r;
double g;
};
void drawrose(int x, int y, int size) {
int i;
double th;
struct DOT rose[360];
for (i = 0; i < 360; i++) {
th = i * 3.1415926 / 180;
rose[i].x = size * sin(th) * sin(th) * sin(th);
rose[i].y = size * cos(th) * sin(th) * sin(th);
rose[i].z = size * cos(th);
rose[i].r = 255 * sin(th) * sin(th);
rose[i].g = 255 * cos(th) * cos(th);
}
for (i = 0; i < 360; i++) {
putpixel(x + rose[i].x, y + rose[i].y, RGB(rose[i].r, rose[i].g, 128));
}
}
int main() {
initgraph(640, 480);
drawrose(320, 240, rosesize);
getch();
closegraph();
return 0;
}
阅读全文