用C语言画个爱心给你的女神

C语言写的控制台程序,黑白界面,略显枯燥,这里介绍个easyx库

EasyX Graphics Library 是针对 Visual C++ 的绘图库

详情请看:EasyX库使用入门

下面我们借用easyx库

一起来画个爱心给你的女神吧!

#include <graphics.h>
#include <conio.h>
#include <math.h>
#include<Windows.h>
void heart(int x0, int y0, int size, COLORREF C)
{
	double  m, n, x, y; double i;
	//设置圆点的颜色
	setfillcolor(RGB(221, 0, 27));
	for (i = 0; i <= 2 * size; i = i + 0.02)
	{
		//产生极坐标点
		m = i;
		n = -size * (((sin(i)*sqrt(fabs(cos(i)))) / (sin(i) + 1.4142)) - 2 * sin(i) + 2);
		//转换为笛卡尔坐标
		x = n * cos(m) + x0;
		y = n * sin(m) + y0;
		//画小圆点
		fillcircle(x, y, 3);
		//延时
		Sleep(30);
	}
}
void text(int x , int y , int speed) {
	//设置字体颜色
	settextcolor(RGB(221, 0, 27));
	//设置字体样式
	settextstyle(20, 0, L"幼圆");
	setbkmode(TRANSPARENT);
	
	outtextxy(x += 30, y, L"送");
	//延时输出
	Sleep(speed);
	outtextxy(x += 30, y, L"你");
	Sleep(speed);
	outtextxy(x += 30, y, L"一");
	Sleep(speed);
	outtextxy(x += 30, y, L"个");
	Sleep(speed);
	outtextxy(x += 30, y, L"小");
	Sleep(speed);
	outtextxy(x += 30, y, L"心");
	Sleep(speed);
	outtextxy(x += 30, y, L"心");
	Sleep(speed);
}
int main()
{
	//设置窗口大小
	initgraph(640, 480);
	//设置背景颜色
	setbkcolor(WHITE);
	cleardevice();
	//输出文本
	text(170,30,200);
	//画爱心
	heart(300, 130, 80, RGB(221, 0, 27));
	//关闭绘图窗口
	closegraph();
	return 0;
}

请添加图片描述

  • 15
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

冰咖啡iii

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值