C++之Easyx——图形库的基本功能(3):形状绘制(上)

6 篇文章 0 订阅
5 篇文章 0 订阅

目录

                                                                      目录

目录

一、bar

        函数定义

        使用说明

                示例程序

二、circle

        函数定义

        使用说明

                示例程序

三、rectangle

        函数定义

       使用说明

                示例程序

 四、arc

        函数定义

        使用说明

                参考线

                 示例程序


一、bar

        函数定义

void EGEAPI bar(int left, int top, int right, int bottom, PIMAGE pimg = NULL);   

        使用说明

bar(左上顶点x坐标, 左上顶点y坐标, 右下顶点x坐标, 右下顶点y坐标);

绘制一个无边框填充长方形

注意!

这一次定义颜色必须使用setfillcolor定义填充色,使用setcolor是不行的,因为无边框。 

                示例程序

#include <graphics.h>

int main()
{
    initgraph(640, 480);
    setfillcolor(GREEN);
	bar(100,100, 300, 200);
	system("pause");
    closegraph();
    return 0;
}

二、circle

        函数定义

void EGEAPI circle(int x, int y, int radius, PIMAGE pimg = NULL);

        使用说明

circle(圆心的x坐标, 圆心的y坐标, 圆的半径)

画一个圆(不可以是椭圆)。

                示例程序

#include <graphics.h>
using namespace std;

int main(void)
{
	initgraph(500, 500);
	circle(250, 250, 200);
	system("pause");
	return 0;
}

                如果程序不出错,应该是这样的:

三、rectangle

        函数定义

void EGEAPI rectangle(int left, int top, int right, int bottom, PIMAGE pimg = NULL);   // 画矩形

       使用说明

rectangle(左上顶点x坐标, 左上顶点y坐标, 右下顶点x坐标, 右下顶点y坐标);

画一个从(左上顶点x坐标, 左上顶点y坐标)到( 右下顶点x坐标, 右下顶点y坐标)的不填充长方形边框。

                示例程序

#include <graphics.h>
using namespace std;

int main(void)
{
	initgraph(250, 250);
	rectangle(50, 50, 200, 200);
	system("pause");
	return 0;
}

 四、arc

        函数定义

void EGEAPI arc(int x, int y, int stangle, int endangle, int radius, PIMAGE pimg = NULL);                  // 画圆弧

        使用说明

arc(圆心x坐标, 圆心y坐标, 从参考线倾斜......度开始画, 在参考线倾斜......度停止画, int 半径);                  // 画圆弧

画一个不完整的、不填充的圆(圆弧)。

                参考线

                那参考线是哪一条呢?

                就是圆心向右延伸的半径。

                不懂?我来画一个图和一个示例程序解释一下。

#include<graphics.h>
int main(){
	initgraph(400,400);
	arc(200,200,150,350,100);
	getch();
	closegraph();
	return 0;
}

                 示例程序

#include<graphics.h>
int main(){
	initgraph(400,400);
	arc(200,200,150,350,100);
	getch();
	closegraph();
	return 0;
}

  • 8
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

快乐星空Maker

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

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

打赏作者

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

抵扣说明:

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

余额充值