SimpleCG库绘制图形函数

        本篇文章将介绍SimpleCG库中使用的所有图形绘制函数,通过这些基础图形将可以构建一切矢量图形组成的图画。理论上有了这些函数,加上你的艺术细胞将可以绘制出一切图画。特别是线条简单的卡通画。

        绘制函数整体概括和命名方式,对于可填充图形,将有三种模式:线框模式、内填充模式、线框+内填充模式。以圆形为例,circle表示线框模式,solidcircle表示内填充模式,fillcirle表示既有线框也有内填充。

        绘制图形相关函数列表(shape.h中声明):

1、画点

//在坐标(nX,nY)处以32位颜色值nColor绘制一个点
void putpixel( int nX, int nY, COLORREF nColor );

2、获取某点颜色


//获取点(nX,nY)处的32位颜色值
COLORREF getpixel( int nX, int nY );

3、画线条

//从坐标(nStartX, nStartY)到(nEndX, nEndY)以当前线颜色绘制一条直线段
void line( int nStartX, int nStartY, int nEndX, int nEndY );

//从当前隐含坐标到(nEndX, nEndY)以当前线颜色绘制一条直线段
void lineto( int nEndX, int nEndY );

//从当前隐含坐标往X方向的nEndX单位, Y方向的nEndY单位的位置,以当前线颜色绘制一条直线段
void linerel(int nDeltaX,int nDeltay);

4、矩形

//以下矩形左上角坐标(left, top),右下角坐标(right,bottom )
//以线条颜色绘制边框,以填充颜色填充内部

//画无填充矩形
void rectangle( int left, int top, int right, int bottom );

//画无边框填充矩形
void solidrectangle( int left, int top, int right, int bottom );

//画填充矩形
void fillrectangle( int left, int top, int right, int bottom );

//清空矩形,以背景色清空矩形
void clearrectangle( int left, int top, int right, int bottom );

5、绘制圆

//圆心坐标(nXCenter,nYCenter),半径为nRatio

//绘无填充制圆
void circle( int nXCenter, int nYCenter, int nRatio );

//绘制填充圆
void fillcircle( int nXCenter, int nYCenter, int nRatio );

//绘制无边框填充圆
void solidcircle( int nXCenter, int nYCenter, int nRatio );

//清空圆
void clearcircle( int nXCenter, int nYCenter, int nRatio );

6、绘制椭圆

//椭圆左上角坐标(left, top),右下角坐标(right, bottom)

//画无填充椭圆
void ellipse( int left, int top, int right, int bottom );

//画无边框填充椭圆
void solidellipse( int left, int top, int right, int bottom );

//画填充椭圆
void fillellipse( int left, int top, int right, int bottom );

//清空椭圆
void clearellipse( int left, int top, int right, int bottom );

7、画圆角矩形

//圆角矩形左上角坐标(left,top),右下角坐标(right, bottom),圆角宽度roundwidth,圆角高度roundheight

//画无填充圆角矩形
void roundrect( int left, int top, int right, int bottom, int roundwidth, int roundheight );

//画无边框填充圆角矩形
void solidroundrect( int left, int top, int right, int bottom, int roundwidth, int roundheight );

//画填充圆角矩形
void fillroundrect( int left, int top, int right, int bottom, int roundwidth, int roundheight );

//清空圆角矩形
void clearroundrect( int left, int top, int right, int bottom, int roundwidth, int roundheight );

8、画扇形

//扇形所在椭圆的外切矩形左上角坐标(left, top),右下角坐标(right, bottom),起始角度stangle,终止角度endangle,角度采用弧度表示,也就是单位圆的弧长度

//画无填充扇形
void pie( int left, int top, int right, int bottom, double stangle, double endangle );

//画无边框填充扇形
void solidpie( int left, int top, int right, int bottom, double stangle, double endangle );

//画填充扇形
void fillpie( int left, int top, int right, int bottom, double stangle, double endangle );

//清空扇形
void clearpie( int left, int top, int right, int bottom, double stangle, double endangle );

9、画多边形

//多边形以一组POINT表示的点坐标数组ptPoints为顶点,nNum表示数组中的点数量

//画无填充多边形
void polygon( const POINT *ptPoints, int nNum );

//画无边框填充多边形
void solidpolygon( const POINT *ptPoints, int nNum );

//画填充多边形
void fillpolygon( const POINT *ptPoints, int nNum );

//清空多边形
void clearpolygon( const POINT *ptPoints, int nNum );

10、绘制一系列折线段 

//折线段以一组POINT表示的点坐标数组ptPoints为端点,nNum表示数组中的点数量
void polyline( const POINT *ptPoints, int nNum );

11、绘制一系列贝塞尔曲线

//数组中开始四个点表示贝塞尔曲线起点,控制点1,控制点2,终点
//其中终点将作为下一段塞尔曲线起点,然后是第二段控制点1,控制点2,终点,循环下去
//所以nNum最少有四个点,总共有3*n+1个点
void polybezier( const POINT *ptPoints, int nNum );

12、绘制一条曲线,nLength指定拉伸曲度

//绘制一条起点(nStartX, nStartY),到终点(nEndX, nEndY)的曲线,nLength越大曲线越弯曲
void curveline( int nStartX, int nStartY, int nEndX, int nEndY, int nLength );

13、画椭圆弧

//椭圆弧所在椭圆的外切矩形左上角坐标(left, top),右下角坐标(right, bottom),起始角度stangle,终止角度endangle,角度采用弧度表示,也就是单位圆的弧长度
void arc( int left, int top, int right, int bottom, double stangle, double endangle );

14、填充区域

//以点(nStartX, nStartY)为起点,开始填充区域,nFillType=enumFFT_BORDER时,填充nColor边线围成的区域。
//当nFillType=enumFFT_SURFACE时,填充nColor指定的一块颜色
void floodfill( int nStartX, int nStartY, COLORREF nColor, int nFillType );

15、绘制一系列曲线,pLength指定每个线段拉伸强度

//一系列曲线以一组POINT表示的点坐标数组ptPoints为端点,nNum表示数组中的点数量以及曲度pLength的元素数量,pLength的数量为nNum-1。
void polycurvelinevar( const POINT *ptPoints, int *pLength, int nNum );

16、绘制一条波浪线

//绘制一条起点(nStartX, nStartY),到(nEndX, nEndY)波浪线,nLength指定拉伸曲度,nNumLine指定波浪数
void _wavyline( int nStartX, int nStartY, int nEndX, int nEndY, int nLength, int nNumLine );

以上是所有可绘制的基础图形,下一篇将以一个个实例对每一个函数的使用方法进行详细讲解。

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

b2b160

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

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

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

打赏作者

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

抵扣说明:

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

余额充值