全屏爱⼼c代码
#include<stdio.h>
//#include<tchar.h>
#include<Windows.h>
#include<math.h>
#include<time.h>
#define PI 3.1415926
#define MAX_WIDTH GetSystemMetrics(SM_CXSCREEN)
#define MAX_HEIGHT GetSystemMetrics(SM_CYSCREEN)
#define ANSI_COLOR_RED "\x1b[31m"
#define ANSI_COLOR_RELAX "\x1b[0m"
void DrawHeart(HDC hdc, double x, double y)
{
int size = rand() % 10 + 1;//更改爱⼼⼤⼩,将数字10更改即可
int max = pow(size, 2) * 100;//更改速度与像素,将数字100更改即可
COLORREF color = RGB(rand() % 256, rand() % 256, rand() % 256);//随机颜⾊
//COLORREF color = RGB(237, 28, 36);//固定爱⼼红⾊
for (int i = 0; i < max; ++i)
{
double t = (double)i / max * 2 * PI;//0<=t<=2*PI
用phpstudy搭建网站SetPixel(hdc, x + size * 16 * pow(sin(t), 3), y - size * (13 * cos(t) - 5 * cos(2 * t) - 2 * cos(3 * t) - cos(4 * t)),color); }
}
int main()
{
srand((unsigned)time(NULL));
HWND hwnd;
HDC hdc;
hwnd = GetDesktopWindow();
hdc = GetWindowDC(hwnd);
for (int i = 0; i < 99; ++i)//更改爱⼼数量,将数字99更改即可
{
printf(ANSI_COLOR_RED "Love You" ANSI_COLOR_RELAX "\n");
DrawHeart(hdc, rand() % MAX_WIDTH, rand() % MAX_HEIGHT);
}
system("pause");
return 0;
}
其中函数调⽤不再多做说明,⾕歌百度都可,狗头保命。
转载请与博主申明!

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。