给自己的奖状
原创简单C语言研究2022-10-01 11:22发表于宁夏
收录于合集#绘制11个
使用 C语言给自己写个奖状吧,先看效果,后附代码
源码如下:
///////////////////////////////////////////////////// 程序名称:奖状生成器// 编译环境:Mictosoft Visual Studio 2013, EasyX_20200315(beta)// 作 者:luoyh <2864292458@qq.com>// 最后修改:2022-9-22//#include<graphics.h>#include<conio.h>#include<math.h>#define PI acos(-1.0)void YZ(int x,int y); // 绘制印章void DrawCircle(TCHAR str, int variable, int fors, int R,int x,int y);int main(){ initgraph(640,480); float H = 26; // 色相 float S = 0.99; // 饱和度 float L = 0.5f; // 亮度 float N = 61 - H; for (int y = 0; y < 480; y++) { if (y < 240) { H += N / 240.f; } else { H -= N / 240.f; } setlinecolor(HSLtoRGB(H, S, L)); line(0, y, 639, y); } setlinecolor(RGB(252,255,230)); setlinestyle(PS_SOLID,6); line(38, 0, 38, 480); line(57, 0, 57, 480); line(77, 0, 77, 480); line(640-38, 0, 640-38, 480); line(640-57, 0, 640-57, 480); line(640-77, 0, 640-77, 480); // 绘制文字 RECT r = { 77, 54, 640-77, 120 }; settextstyle(60,0,_T("楷体")); setbkmode(TRANSPARENT); settextcolor(RGB(245,4,0)); drawtext(_T("奖 状"), &r, DT_CENTER | DT_VCENTER | DT_SINGLELINE); settextstyle(25, 0, _T("楷体")); settextcolor(BLACK); outtextxy(124, 168 - 35, _T("C语言研究:")); outtextxy(158, 200 - 30, _T("由于你这段时间的优良表现,现在")); outtextxy(120, 244 - 30, _T("授予你“最佳创作者”希望你继续保")); outtextxy(120, 288 - 30, _T("持,在今后的日子里,再接再厉!")); YZ(480, 360); settextcolor(BLACK); settextstyle(18, 0, L"楷体", 0, 0, 0, false, false, false, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, ANTIALIASED_QUALITY, DEFAULT_PITCH); outtextxy(380,342,_T("给C语言研究的专属奖状")); outtextxy(380,360, _T("二〇二二年九月二十二日")); saveimage(_T("a.png")); _getch(); return 0;}void YZ(int x,int y){ int R = 50; setlinecolor(RGB(255,3,1)); setlinestyle(PS_SOLID, 3); circle(x,y,R); // 五角星 POINT pts[5]; // 计算五角星的五个顶点坐标 double a =