[Easyx]一个以图像模式输出圆角矩形的函数

您所在的位置:网站首页 procreate怎么画圆角方形 [Easyx]一个以图像模式输出圆角矩形的函数

[Easyx]一个以图像模式输出圆角矩形的函数

2024-07-12 19:26:41| 来源: 网络整理| 查看: 265

前言:虽然easyx里面有一个这个功能的函数了,但是我还是自制了一种实现方式来练习下。

附加-easyx中的圆角矩形函数:

void roundrect (int left, int top, int right, int bottom, int ellipsewidth, int ellipseheight); // 画圆角矩形 void fillroundrect (int left, int top, int right, int bottom, int ellipsewidth, int ellipseheight); // 画填充圆角矩形(有边框) void solidroundrect(int left, int top, int right, int bottom, int ellipsewidth, int ellipseheight); // 画填充圆角矩形(无边框) void clearroundrect(int left, int top, int right, int bottom, int ellipsewidth, int ellipseheight); // 清空圆角矩形区域

好,正式开始介绍:

示例图: 在这里插入图片描述 函数:

void out_long(//制作长方体,圆角长方体 int left, int top, int right, int bottom, //上下左右点的坐标 bool line = false, //是否启用边框,默认不用 COLORREF color_full = WHITE, //填充色(默认为白) COLORREF color_line = BLACK, //边框颜色(默认为黑) unsigned int r = 0 //圆半径,0的时候无圆角 ) { setlinecolor(color_line); // 设置当前线条颜色 setfillcolor(color_full); // 设置当前填充颜色 if (!r) {//如果没有半径,就是输出普通长方体 if (line)//如果有边框 fillrectangle(left, top, right, bottom); else solidrectangle(left, top, right, bottom); } else {//输出带圆角长方体 if (line) {//如果有边框 fillcircle(left + r, top + r, r); fillcircle(left + r, bottom - r, r); fillcircle(right - r, top + r, r); fillcircle(right - r, bottom - r, r); solidrectangle(left, top + r, right, bottom - r); solidrectangle(left + r, top, right - r, bottom); ::line(left + r, top, right - r, top); ::line(left + r, bottom, right - r, bottom); ::line(left, top + r, left, bottom - r); ::line(right, top + r, right, bottom - r); } else { solidrectangle(left, top + r, right, bottom - r); solidrectangle(left + r, top, right - r, bottom); solidcircle(left + r, top + r, r); solidcircle(left + r, bottom - r, r); solidcircle(right - r, top + r, r); solidcircle(right - r, bottom - r, r); } } }

完整代码:

#include #include void out_long(//制作长方体,圆角长方体 int left, int top, int right, int bottom, //上下左右点的坐标 bool line = false, //是否启用边框,默认不用 COLORREF color_full = WHITE, //填充色(默认为白) COLORREF color_line = BLACK, //边框颜色(默认为黑) unsigned int r = 0 //圆半径,0的时候无圆角 ) { setlinecolor(color_line); // 设置当前线条颜色 setfillcolor(color_full); // 设置当前填充颜色 if (!r) {//如果没有半径,就是输出普通长方体 if (line)//如果有边框 fillrectangle(left, top, right, bottom); else solidrectangle(left, top, right, bottom); } else {//输出带圆角长方体 if (line) {//如果有边框 fillcircle(left + r, top + r, r); fillcircle(left + r, bottom - r, r); fillcircle(right - r, top + r, r); fillcircle(right - r, bottom - r, r); solidrectangle(left, top + r, right, bottom - r); solidrectangle(left + r, top, right - r, bottom); ::line(left + r, top, right - r, top); ::line(left + r, bottom, right - r, bottom); ::line(left, top + r, left, bottom - r); ::line(right, top + r, right, bottom - r); } else { solidrectangle(left, top + r, right, bottom - r); solidrectangle(left + r, top, right - r, bottom); solidcircle(left + r, top + r, r); solidcircle(left + r, bottom - r, r); solidcircle(right - r, top + r, r); solidcircle(right - r, bottom - r, r); } } } int main() { initgraph(500, 500); setbkcolor(0xfffff1); cleardevice();//清下屏 out_long(10, 10, 50, 50);//默认输出 out_long(10, 60, 50, 100, true);//带边框 out_long(10, 110, 50, 150, true,0xAAAAAA);//带边框,且填充内部颜色 out_long(10, 160, 50, 200, true, 0x00Bfff, 0xFF3030);//带边框,且填充内部颜色,还加了边框色 out_long(10, 210, 50, 250, true, 0xffffff, 0xFF3030,20);//带边框,且填充内部颜色,还加了边框色,设置了边角的半径 //吐槽:一个像圆的圆角长方体 out_long(10, 260, 200, 400, true, 0xAAAAAA, 0xADFF2F, 20);//带边框,且填充内部颜色,还加了边框色,设置了边角的半径 //正常了 out_long(10, 410, 400, 490, true, 0xf0f0f0, 0x87CEFA, 20);//带边框,且填充内部颜色,还加了边框色,设置了边角的半径 _getch();//不过不行就换成getch(); closegraph(); return 0; }


【本文地址】

公司简介

联系我们

今日新闻


点击排行

实验室常用的仪器、试剂和
说到实验室常用到的东西,主要就分为仪器、试剂和耗
不用再找了,全球10大实验
01、赛默飞世尔科技(热电)Thermo Fisher Scientif
三代水柜的量产巅峰T-72坦
作者:寞寒最近,西边闹腾挺大,本来小寞以为忙完这
通风柜跟实验室通风系统有
说到通风柜跟实验室通风,不少人都纠结二者到底是不
集消毒杀菌、烘干收纳为一
厨房是家里细菌较多的地方,潮湿的环境、没有完全密
实验室设备之全钢实验台如
全钢实验台是实验室家具中较为重要的家具之一,很多

推荐新闻


图片新闻

实验室药品柜的特性有哪些
实验室药品柜是实验室家具的重要组成部分之一,主要
小学科学实验中有哪些教学
计算机 计算器 一般 打孔器 打气筒 仪器车 显微镜
实验室各种仪器原理动图讲
1.紫外分光光谱UV分析原理:吸收紫外光能量,引起分
高中化学常见仪器及实验装
1、可加热仪器:2、计量仪器:(1)仪器A的名称:量
微生物操作主要设备和器具
今天盘点一下微生物操作主要设备和器具,别嫌我啰嗦
浅谈通风柜使用基本常识
 众所周知,通风柜功能中最主要的就是排气功能。在

专题文章

    CopyRight 2018-2019 实验室设备网 版权所有 win10的实时保护怎么永久关闭