成人午夜视频全免费观看高清-秋霞福利视频一区二区三区-国产精品久久久久电影小说-亚洲不卡区三一区三区一区

c語言如何實現(xiàn)玫瑰花

c語言實現(xiàn)玫瑰花的方法:首先定義全局變量,并定義結(jié)構(gòu)體;然后設(shè)置輸出花柄、花柄、綠葉、花萼;最后創(chuàng)建繪圖窗口,輸出完整花朵。

創(chuàng)新互聯(lián)公司專業(yè)為企業(yè)提供渭南網(wǎng)站建設(shè)、渭南做網(wǎng)站、渭南網(wǎng)站設(shè)計、渭南網(wǎng)站制作等企業(yè)網(wǎng)站建設(shè)、網(wǎng)頁設(shè)計與制作、渭南企業(yè)網(wǎng)站模板建站服務(wù),十年渭南做網(wǎng)站經(jīng)驗,不只是建網(wǎng)站,更提供有價值的思路和整體網(wǎng)絡(luò)服務(wù)。

c語言實現(xiàn)玫瑰花的方法:

#include <stdio.h>
#include <windows.h>?
#include <math.h>
#include <graphics.h>
#include <mmsystem.h>
#pragma comment(lib,"winmm.lib")
//定義全局變量
int rosesize = 500;
int h = -250;
//定義結(jié)構(gòu)體
struct DOT {
double x;
double y;
double z;
double r;
double g;
};
 
bool calc(double a,double b,double c,DOT &d) {
double j, n, o, w, z;
 
if (c > 60) { //花柄
d.x = sin(a * 7)*(13 + 5 / (0.2 + pow(b * 4, 4))) - sin(b) * 50;
d.y = b*rosesize + 50;
d.z = 625 + cos(a * 7)*(13 + 5 / (0.2 + pow(b * 4, 4))) + b * 400;
d.r = a * 1 - b / 2;
d.g = a;
return true;
}
double A = a * 2 - 1;
double B = b * 2 - 1;
if (A*A + B*B < 1) { //綠葉
if (c > 37) {
j = (int(c) & 1);
n = j ? 6 : 4;
o = 0.5 / (a + 0.01) + cos(b * 125) * 3 - a * 300;
w = b * h;
d.x = o * cos(n) + w * sin(n) + j * 610 - 390;
d.y = o * sin(n) - w * cos(n) + 550 - j * 350;
d.z = 1180 + cos(B + A) * 99 - j * 300;
d.r = 0.4 - a * 0.1 + pow(1 - B * B, -h * 6) * 0.15 - a * b * 0.4 + cos(a + b) / 5 +
      pow(cos((o * (a + 1) + (B > 0 ? w : -w)) / 25), 30) * 0.1 * (1 - B * B);
d.g = o / 1000 + 0.7 - o * w * 0.000003;
return true;
}
 
if (c > 32) { //花萼
c = c*1.16 - 0.15;
o = a * 45 - 20;
w = b * b * h;
z = o * sin(c) + w * cos(c) + 620;
d.x = o * cos(c) - w * sin(c);
d.y = 28 + cos(B * 0.5) * 99 - b * b * b * 60 - z / 2 - h;
d.z = z;
d.r = (b * b * 0.3 + pow((1 - (A * A)), 7)*0.15 + 0.3)*b;
d.g = b * 0.7;
return true;
}
 
//花朵
o = A*(2 - b)*(80 - c * 2);
w = 99 - cos(A) * 120 - cos(b)*(-h - c * 4.9) + cos(pow(1 - b, 7)) * 50 + c * 2;
z = o * sin(c) + w * cos(c) + 700;
d.x = o * cos(c) - w * sin(c);
d.y = B * 99 - cos(pow(b, 7)) * 50 - c / 3 - z / 1.35 + 450;
d.z = z;
d.r = (1 - b / 1.2) * 0.9 + a * 0.1;
d.g = pow((1 - b), 20) / 4 + 0.05;
return true;
}
 
return false;
}
 
int main()
{
short ?*zBuffer;
int x, y, z, zBufferIndex;
DOT dot;
initgraph(640,480);//創(chuàng)建繪圖窗口
 
/*添加音樂*/
mciSendString("open BadApple.mp3 alias BadApple", NULL, 0, NULL);
mciSendString("play BAdApple", NULL, 0, NULL);
 
setbkcolor(YELLOW);
cleardevice();
zBuffer = new short[rosesize * rosesize];
memset(zBuffer, 0, sizeof(short) * rosesize * rosesize);
for (int j = 0; j < 2000; j++)// && !_kbhit()
{
for (int i = 0; i < 10000; i++)
if (calc(double(rand()) / RAND_MAX, double(rand()) / RAND_MAX, rand() % 46 / 0.74, dot))
{
z = int(dot.z + 0.5);
x = int(dot.x*rosesize / z - h + 0.5);
y = int(dot.y*rosesize / z - h + 0.5);
if (y > rosesize) continue;
zBufferIndex = y*rosesize + x;
if (!zBuffer[zBufferIndex] || zBuffer[zBufferIndex] > z)
{
zBuffer[zBufferIndex] = z;
//畫點
int r = ~int((dot.r*h));
?
if (r < 0)r = 0;
?
if (r > 255)r = 255;
 
int g = ~int((dot.g*h));
if (g < 0)g = 0;
if (g > 255)g = 255;
 
int b = ~int((dot.r*dot.r*-80));
if (b < 0)b = 0;
if (b > 255)b = 255;
 
putpixel(x + 50, y - 20, RGB(r, g, b));
}
}
Sleep(100);
}
delete[]zBuffer;
getchar();
closegraph();
return 0;
}

相關(guān)學(xué)習推薦:C視頻教程

本文名稱:c語言如何實現(xiàn)玫瑰花
標題URL:http://jinyejixie.com/article10/cphhgo.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供面包屑導(dǎo)航網(wǎng)站策劃、自適應(yīng)網(wǎng)站網(wǎng)站收錄、App設(shè)計云服務(wù)器

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

網(wǎng)站托管運營
莲花县| 甘南县| 玛曲县| 轮台县| 南江县| 定远县| 交城县| 红河县| 蒙阴县| 社会| 虞城县| 和硕县| 合肥市| 唐河县| 泽普县| 阿城市| 广昌县| 射洪县| 合江县| 定安县| 凌云县| 英山县| 阳东县| 沂南县| 汝州市| 多伦县| 宁夏| 临桂县| 长汀县| 饶阳县| 榆林市| 广昌县| 屏东市| 即墨市| 图木舒克市| 宁陕县| 东山县| 宜宾县| 江西省| 双桥区| 墨竹工卡县|